summaryrefslogtreecommitdiff
path: root/grid5000/steps/export/do_qcow2_finish_works.yaml
diff options
context:
space:
mode:
Diffstat (limited to 'grid5000/steps/export/do_qcow2_finish_works.yaml')
-rw-r--r--grid5000/steps/export/do_qcow2_finish_works.yaml44
1 files changed, 44 insertions, 0 deletions
diff --git a/grid5000/steps/export/do_qcow2_finish_works.yaml b/grid5000/steps/export/do_qcow2_finish_works.yaml
new file mode 100644
index 0000000..be80e25
--- /dev/null
+++ b/grid5000/steps/export/do_qcow2_finish_works.yaml
@@ -0,0 +1,44 @@
+# Install cloud_init in qcow2 output file (tarball must be exported beforehand, in order to not include cloud_init)
+- install_cloud_init:
+ - exec_local: |
+ if [[ "$${appliance_formats}" =~ "qcow2" ]]; then
+ echo "Install cloud_init in qcow2"
+ # First unset any proxy variable (set to http://127.0.0.1:8000 if kameleon's cache is enabled) so that virt-customise works ok
+ (for e in $(env | grep -i _proxy); do unset ${e%%=*}; done; virt-customize -a $${output}.qcow2 --install cloud-init)
+ echo "Configure datasource and timeout for cloud_init"
+ virt-customize -a $${output}.qcow2 --run-command 'printf "datasource_list: [ NoCloud, Ec2, None ]\n" > /etc/cloud/cloud.cfg.d/91-set-datasources.cfg'
+ virt-customize -a $${output}.qcow2 --run-command 'printf "datasource:\n Ec2:\n timeout: 3\n max_wait: -1\n" > /etc/cloud/cloud.cfg.d/92-set-ec2-timeout.cfg'
+ # Remove DHCP hook to let cloud-init handle hostname
+ virt-customize -a $${output}.qcow2 --run-command 'rm -f /etc/dhcp/dhclient-exit-hooks.d/g5k-update-host-name'
+ else
+ echo "No qcow2 export, nothing to do."
+ fi
+
+- fix_interface_name:
+ - exec_local: |
+ if [[ "$${appliance_formats}" =~ "qcow2" && "$${distrib}" == "debian" ]]; then
+ virt-customize -a $${output}.qcow2 --run-command 'sed -i s/ens3/enp0s2/ /etc/network/interfaces'
+ else
+ echo "Nothing to do."
+ fi
+
+- setup_uefi_boot:
+ - exec_local: |
+ if [[ "$${qemu_uefi}" == "true" ]] && [[ "$${arch}" == "aarch64" ]] && [[ "$${appliance_formats}" =~ "qcow2" ]]; then
+ echo "Setting up ARM64 UEFI boot for qcow2 image"
+ virt-customize \
+ -a $${output}.qcow2 \
+ --run-command 'if ! [ -e /boot/efi/EFI/BOOT/BOOTAA64.EFI ]; then mkdir -p /boot/efi/EFI/BOOT ; cp /boot/efi/EFI/$${distrib}/grubaa64.efi /boot/efi/EFI/BOOT/BOOTAA64.EFI; fi'
+ else
+ echo "Nothing to do."
+ fi
+
+- sparsify_qcow2_image:
+ - exec_local: |
+ if [[ "$${appliance_formats}" =~ "qcow2" ]]; then
+ echo "Compress and reduce qcow2 size"
+ virt-sparsify --compress $${output}.qcow2 $${output}.qcow2.sparsed
+ mv -f $${output}.qcow2.sparsed $${output}.qcow2
+ else
+ echo "No qcow2 export, nothing to do."
+ fi