copr-be: drop unused scripts

This commit is contained in:
Pavel Raiskup 2021-10-12 14:58:44 +02:00
parent 43bc598fb1
commit a58b26c101
3 changed files with 0 additions and 113 deletions

View file

@ -58,8 +58,6 @@
template: src="resalloc/{{ item }}" dest="/var/lib/resallocserver/resalloc_provision/"
mode=755
with_items:
- vm-aws-new
- vm-aws-delete
- vm-check
- vm-release
tags:

View file

@ -1,6 +0,0 @@
#! /bin/sh -x
die() { echo "$*" >&2 ; exit 1; }
test -n "$RESALLOC_NAME" || die "no RESALLOC_NAME"
ansible-playbook /var/lib/resallocserver/provision/terminatepb-aws.yml \
--extra-vars '{"copr_task": {"vm_name": "'"$RESALLOC_NAME"'"}}'

View file

@ -1,105 +0,0 @@
#! /usr/bin/bash
set -e
set -o pipefail
delete_script=$(readlink -f "$(dirname "$0")")/vm-aws-delete
show_help()
{
cat <<EOHELP >&2
Usage: $0 --arch ARCH
Allocate AWS VM instance for Copr build system.
Options:
--arch native architecture (required)
-h, --help show this help
--spot start a spot instance
Environment variables:
\$RESALLOC_NAME the name given to the allocated instance, will be
later used for termination, too
EOHELP
test -z "$1" || exit "$1"
}
set -x
# handle no arguments
test $# -eq 0 && show_help 1
test -n "$RESALLOC_NAME" || show_help 1
ARGS=$(getopt -o "h" -l "arch:,spot,help" -n "getopt" -- "$@") \
|| show_help 1
eval set -- "$ARGS"
opt_arch=
opt_spot=false
while true; do
# now the name is in $1 and argument in $2
case $1 in
--arch)
opt=${1##--}
opt=${opt##-}
opt=${opt//-/_}
eval "opt_$opt=\$2"
shift 2
;;
--spot)
opt=${1##--}
opt=${opt##-}
opt=${opt//-/_}
eval "opt_$opt=:"
shift
;;
-h|--help) show_help 0;;
--) # end!
shift; break;;
*) echo "programmer mistake ($1)" >&2; exit 1;;
esac
done
case $opt_arch in
x86_64|aarch64) ;;
*) echo >&2 "wrong arch: $opt_arch"; show_help 1;;
esac
test -n "$opt_arch" || show_help 1
cleanup_vm=true
cleanup_actions()
{
if $cleanup_vm; then
# it is safe to ask for removal of non-existeng VM (in case the playbook
# below was shut-down before the VM was even created)
$delete_script || :
exit 1
fi
}
trap cleanup_actions EXIT
spot_pb_part=
if $opt_spot; then
spot_pb_part=-spot
fi
# TODO: We should call aws-cli directly here, instead of parsing output of
# ansible playbook. But at the time of writing this script we had the playbook
# available, so parsing the output is the easiest way to start.
playbook=/var/lib/resallocserver/provision/builderpb-aws"$spot_pb_part"-"$opt_arch".yml
{
vm_ip=$(ansible-playbook "$playbook" \
--extra-vars '{"vm_name": "'"$RESALLOC_NAME"'"}' \
|& tee >(cat - >&$stderr_fd) \
| sed -n 's/.*"VM_IP=\(.*\)"/\1/p' )
} {stderr_fd}>&2
echo "$vm_ip"
test -n "$vm_ip"
# successfuly created, disable cleanup action
cleanup_vm=false