copr-hv: templated provision scripts
This commit is contained in:
parent
9b77fd9450
commit
8249f6fdbc
2 changed files with 41 additions and 0 deletions
|
@ -23,6 +23,18 @@
|
|||
tags:
|
||||
- provision_config
|
||||
|
||||
- name: templated provision scripts
|
||||
template:
|
||||
src: "{{ roles_path }}/copr/backend/templates/provision/{{ item }}"
|
||||
dest: "{{ provision_directory }}/{{ item }}"
|
||||
mode: 0755
|
||||
with_items:
|
||||
- upload-qcow2-images
|
||||
tags:
|
||||
- provision_config
|
||||
when:
|
||||
- cloud_vars is not defined
|
||||
|
||||
- name: generate cloud-oriented vars files
|
||||
template:
|
||||
src: "{{ roles_path }}/copr/backend/templates/provision/{{ item }}"
|
||||
|
|
29
roles/copr/backend/templates/provision/upload-qcow2-images
Executable file
29
roles/copr/backend/templates/provision/upload-qcow2-images
Executable file
|
@ -0,0 +1,29 @@
|
|||
#! /bin/bash -x
|
||||
|
||||
die() { echo >&2 "$*" ; exit 1 ; }
|
||||
|
||||
image=$1
|
||||
|
||||
connections='
|
||||
{% for host in groups["copr_hypervisor"] %}
|
||||
qemu+ssh://copr@{{ hostvars[host]['inventory_hostname'] }}/system
|
||||
{% endfor %}
|
||||
'
|
||||
|
||||
new_volume=$2
|
||||
if test -z "$new_volume"; then
|
||||
image_prefix=copr-builder-
|
||||
new_volume=$image_prefix$(date +"%Y%m%d_%H%M%S")
|
||||
fi
|
||||
|
||||
export VIRSH_DEFAULT_CONNECT_URI=
|
||||
|
||||
test -n "$image" || die "first argument (image) required"
|
||||
test -f "$image" || die "image $image not found"
|
||||
|
||||
pool=images
|
||||
for connection in $connections; do
|
||||
virsh --connect="$connection" vol-create-as --pool "$pool" "$new_volume" 1M
|
||||
virsh --connect="$connection" vol-upload --pool "$pool" "$new_volume" --sparse "$image"
|
||||
done
|
||||
echo "uploaded images $new_volume"
|
Loading…
Add table
Add a link
Reference in a new issue