copr: backend: image preparation scripting

This commit is contained in:
Pavel Raiskup 2019-08-14 12:57:58 +02:00 committed by Pierre-Yves Chibon
parent 36ca7d6e17
commit 12d490432f
4 changed files with 86 additions and 0 deletions

View file

@ -0,0 +1,11 @@
#! /bin/bash
. /home/copr/cloud/keystonerc_proper_tenant
set +x
openstack image set \
--unprotected \
"$1"
openstack image delete "$1"

View file

@ -0,0 +1,11 @@
#! /bin/bash
. /home/copr/cloud/keystonerc_proper_tenant
set +x
openstack image set \
--public \
--protected \
--property hw_rng_model=virtio \
"$1"

View file

@ -0,0 +1,53 @@
#! /bin/bash
. /home/copr/cloud/keystonerc_proper_tenant
set -e
arch=$1
die() { echo "$*" >&2 ; exit 1 ; }
case $arch in
ppc64le) playbook=/home/copr/provision/builderpb_nova_ppc64le.yml ;;
x86_64) playbook=/home/copr/provision/builderpb_nova.yml ;;
*) die "bad architecture '$arch'" ;;
esac
logfile="/tmp/prepare-image-os-$arch.log"
ansible_options=( -e prepare_base_image=1 )
test -z "$2" || ansible_options+=( -e image_name="$2" )
ansible-playbook "$playbook" "${ansible_options[@]}" |& tee "$logfile"
vm_name=$(sed -n 's/.*vm_name=\(\w\+\).*/\1/p' "$logfile" | head -1)
test -n "$vm_name"
ip=$(sed -n 's/.*VM_IP=\([0-9\.]\+\).*/\1/p' "$logfile" | head -1)
test -n "$ip"
fedora=$(ssh "root@$ip" 'rpm --eval %fedora')
new_volume_name="copr-builder-$arch-f$fedora-$(date +"%Y%m%d_%H%M%S")"
# we can not just do
# $ nova-3 image-create "$vm_name" "$new_volume_name" --poll
# because it throws error:
# ERROR (ClientException): The server has either erred or is incapable of
# performing the requested operation. (HTTP 500) (Request-ID:...)
nova-3 stop "$vm_name"
cat <<EOF
Please go to https://fedorainfracloud.org/ page, log-in and find the instance
$vm_name
Check that it is in SHUTOFF state. Create a snapshot from that instance, name
it "$new_volume_name". Once snapshot is saved, run:
$ copr-image-fixup-snapshot-os.sh $new_volume_name
And continue with
https://docs.pagure.org/copr.copr/how_to_upgrade_builders.html#how-to-upgrade-builders
EOF

View file

@ -28,6 +28,10 @@
- php-cli
- cronolog
- name: install openstackclient for image preparation
dnf: state=present name=python3-openstackclient
when: devel|bool
# disable this in favor of excluding it in /etc/dnf/dnf.conf.
# https://github.com/ansible/ansible/issues/33187
#- name: install python2-novaclient version that actually works with the current OpenStack deployment
@ -179,6 +183,13 @@
tags:
- provision_config
- name: copy image preparation scripts
copy: src="{{ item }}" dest="/usr/local/bin/{{ item }}"
owner=root mode=755
with_fileglob:
- copr-image-*.sh
when: devel|bool
- name: testing fixture
copy: dest="/home/copr/cloud/ec2rc.variable" content=""
when: devel|bool