From a6ce28314677557427aec77053c0107923822b70 Mon Sep 17 00:00:00 2001 From: Matt Crees Date: Wed, 3 May 2023 11:10:31 +0100 Subject: [PATCH] Replace Cirros references with generic descriptors Often it is beneficial to use the functionality provided by `use_cirros` and `cirros_deploy_image_upstream_url` to download and test with images of other OS distributions. This patch changes the variable names to reflect that use case. `use_cirros` -> `download_custom_deploy_image` `cirros_deploy_image_upstream_url` -> `custom_deploy_image_upstream_url` The functionality of the old variables is retained for backwards compatability. Co-Authored-By: Alex Welsh Change-Id: I8b3a973bd5ef19333af563c170b2a28fbbfb5c76 --- bifrost/cli.py | 2 +- doc/source/install/offline-install.rst | 2 +- playbooks/inventory/group_vars/localhost | 2 +- playbooks/inventory/group_vars/target | 2 +- .../bifrost-configdrives-dynamic/defaults/main.yml | 7 +++++-- .../roles/bifrost-ironic-install/defaults/main.yml | 12 ++++++++---- .../roles/bifrost-ironic-install/tasks/bootstrap.yml | 12 ++++++------ playbooks/test-bifrost.yaml | 4 ++-- .../generalise-use_cirros-be75f2c5452491a1.yaml | 7 +++++++ scripts/test-bifrost.sh | 10 +++++----- tools/vagrant_dev_env/vagrant.yml | 2 +- 11 files changed, 38 insertions(+), 24 deletions(-) create mode 100644 releasenotes/notes/generalise-use_cirros-be75f2c5452491a1.yaml diff --git a/bifrost/cli.py b/bifrost/cli.py index aaa8b1968..4f2c11288 100644 --- a/bifrost/cli.py +++ b/bifrost/cli.py @@ -182,7 +182,7 @@ def cmd_install(args): enabled_hardware_types=args.hardware_types, cleaning_disk_erase=args.cleaning_disk_erase, testing=args.testenv, - use_cirros=args.testenv, + download_custom_deploy_image=args.testenv, use_tinyipa=args.testenv, developer_mode=args.develop, enable_prometheus_exporter=args.enable_prometheus_exporter, diff --git a/doc/source/install/offline-install.rst b/doc/source/install/offline-install.rst index 45b2dad1b..347235b76 100644 --- a/doc/source/install/offline-install.rst +++ b/doc/source/install/offline-install.rst @@ -45,7 +45,7 @@ this. ipa_kernel_upstream_url: file:///vagrant/ipa-centos9-master.kernel ipa_ramdisk_upstream_url: file:///vagrant/ipa-centos9-master.initramfs - cirros_deploy_image_upstream_url: file:///vagrant/cirros-0.5.1-x86_64-disk.img + custom_deploy_image_upstream_url: file:///vagrant/cirros-0.5.3-x86_64-disk.img dib_git_url: file:///vagrant/git/diskimage-builder ironicclient_git_url: file:///vagrant/git/python-ironicclient ironic_git_url: file:///vagrant/git/ironic diff --git a/playbooks/inventory/group_vars/localhost b/playbooks/inventory/group_vars/localhost index eb3ce355c..a828da19f 100644 --- a/playbooks/inventory/group_vars/localhost +++ b/playbooks/inventory/group_vars/localhost @@ -51,7 +51,7 @@ mysql_password: # deploy_image: "{{http_boot_folder}}/{{deploy_image_filename}}" # Setting to utilize diskimage-builder to create a bootable image. -create_image_via_dib: "{{ not use_cirros | default(false) | bool }}" +create_image_via_dib: "{{ not (download_custom_deploy_image | default(use_cirros) | default(false) | bool) }}" dib_image_type: vm # Create IPA image instead of downloading an pre-made IPA image. diff --git a/playbooks/inventory/group_vars/target b/playbooks/inventory/group_vars/target index eb3ce355c..a828da19f 100644 --- a/playbooks/inventory/group_vars/target +++ b/playbooks/inventory/group_vars/target @@ -51,7 +51,7 @@ mysql_password: # deploy_image: "{{http_boot_folder}}/{{deploy_image_filename}}" # Setting to utilize diskimage-builder to create a bootable image. -create_image_via_dib: "{{ not use_cirros | default(false) | bool }}" +create_image_via_dib: "{{ not (download_custom_deploy_image | default(use_cirros) | default(false) | bool) }}" dib_image_type: vm # Create IPA image instead of downloading an pre-made IPA image. diff --git a/playbooks/roles/bifrost-configdrives-dynamic/defaults/main.yml b/playbooks/roles/bifrost-configdrives-dynamic/defaults/main.yml index c9fc379cd..ac666f1c3 100644 --- a/playbooks/roles/bifrost-configdrives-dynamic/defaults/main.yml +++ b/playbooks/roles/bifrost-configdrives-dynamic/defaults/main.yml @@ -15,12 +15,15 @@ internal_ip: "{{ hostvars[ans_hostname]['ansible_' + ans_network_interface]['ipv node_default_network_interface: eth0 testing: false -use_cirros: false + +# Build images by default +download_custom_deploy_image: "{{ use_cirros | default(false) }}" + # write_interfaces_file is intended for utilizing base logic to write # a debian style interfaces file into the configuration drive file # such that cirros will receive basic network configuration when # performing basic testing. -write_interfaces_file: "{{ use_cirros }}" +write_interfaces_file: "{{ download_custom_deploy_image }}" # Basic networking defaults ipv4_subnet_mask: 255.255.255.0 diff --git a/playbooks/roles/bifrost-ironic-install/defaults/main.yml b/playbooks/roles/bifrost-ironic-install/defaults/main.yml index d73987f8e..96ba32682 100644 --- a/playbooks/roles/bifrost-ironic-install/defaults/main.yml +++ b/playbooks/roles/bifrost-ironic-install/defaults/main.yml @@ -24,7 +24,7 @@ sushy_source_install: false staging_drivers_source_install: true prometheus_exporter_source_install: true # Setting to utilize diskimage-builder to create a bootable image. -create_image_via_dib: "{{ not use_cirros | default(false) | bool }}" +create_image_via_dib: "{{ not (download_custom_deploy_image) }}" create_ipa_image: false dib_image_type: vm dib_os_element: "debian" @@ -106,15 +106,19 @@ deploy_image_filename: "deployment_image.qcow2" deploy_image: "{{ http_boot_folder }}/{{ deploy_image_filename }}" esp_image: "{{ http_boot_folder }}/esp.img" esp_image_url: "{{ ipa_file_protocol }}://{{ internal_ip }}:{{ file_url_port }}/esp.img" -# Use cirros instead of building an image via diskimage-builder -use_cirros: false +# Download a deployment image (default cirros) instead of building an image via diskimage-builder +download_custom_deploy_image: "{{ use_cirros | default(false) }}" # Download IPA by default download_ipa: true update_repos: true update_ipa: "{{ update_repos }}" # Use the DIB dynamic-login element to insert the SSH key ipa_add_ssh_key: false -cirros_deploy_image_upstream_url: https://download.cirros-cloud.net/0.5.1/cirros-0.5.1-x86_64-disk.img +# NOTE(Alex-Welsh): cirros_deploy_image_upstream_url has been deprecated in +# favor of custom_deploy_image_upstream_url but is included for backwards +# compatability. It should be swapped permanently to +# custom_deploy_image_upstream_url in the next major release. +custom_deploy_image_upstream_url: "{{ cirros_deploy_image_upstream_url | default('https://download.cirros-cloud.net/0.5.3/cirros-0.5.3-x86_64-disk.img') }}" # By default bifrost will deploy dnsmasq to utilize as an integrated DHCP # server. If you already have a DHCP server or do not need DHCP/TFTP at all, # you can pass --disable-dhcp to the bifrost-cli install command to disable it. diff --git a/playbooks/roles/bifrost-ironic-install/tasks/bootstrap.yml b/playbooks/roles/bifrost-ironic-install/tasks/bootstrap.yml index 00eb8f8bc..7ab3e9fc5 100644 --- a/playbooks/roles/bifrost-ironic-install/tasks/bootstrap.yml +++ b/playbooks/roles/bifrost-ironic-install/tasks/bootstrap.yml @@ -401,18 +401,18 @@ - not create_ipa_image | bool - download_ipa | bool -- when: use_cirros | bool +- when: download_custom_deploy_image | bool block: - - name: "Download cirros to use for deployment if requested" + - name: "Download a custom image to use for deployment if requested" get_url: - url: "{{ cirros_deploy_image_upstream_url }}" + url: "{{ custom_deploy_image_upstream_url }}" dest: "{{ deploy_image }}" owner: ironic group: ironic mode: "0644" rescue: - name: "Attempt to use curl if get_url fails" - command: "curl -L --output {{ deploy_image }} {{ cirros_deploy_image_upstream_url }}" # noqa: command-instead-of-module + command: "curl -L --output {{ deploy_image }} {{ custom_deploy_image_upstream_url }}" # noqa: command-instead-of-module - name: Set file permissions file: path: "{{ deploy_image }}" @@ -420,9 +420,9 @@ group: ironic mode: "0644" -- when: use_cirros | bool +- when: download_custom_deploy_image | bool block: - - name: "Create a checksum file for cirros" + - name: "Create a checksum file for the custom deployment image" shell: md5sum {{ deploy_image_filename }} > {{ deploy_image_filename }}.CHECKSUMS args: chdir: "{{ http_boot_folder }}" diff --git a/playbooks/test-bifrost.yaml b/playbooks/test-bifrost.yaml index 16b084d16..643a74be5 100644 --- a/playbooks/test-bifrost.yaml +++ b/playbooks/test-bifrost.yaml @@ -4,7 +4,7 @@ # Set BIFROST_INVENTORY_SOURCE # export BIFROST_INVENTORY_SOURCE=/tmp/baremetal.json # Execute the installation and VM startup test. -# ansible-playbook -vvvv -i inventory/bifrost_inventory.py test-bifrost.yaml -e use_cirros=true -e testing_user=cirros +# ansible-playbook -vvvv -i inventory/bifrost_inventory.py test-bifrost.yaml -e download_custom_deploy_image=true -e testing_user=cirros --- - hosts: localhost connection: local @@ -19,7 +19,7 @@ block: - name: "Set variables if running in the CI" set_fact: - cirros_deploy_image_upstream_url: file:///opt/cache/files/cirros-0.5.3-x86_64-disk.img + custom_deploy_image_upstream_url: file:///opt/cache/files/cirros-0.5.3-x86_64-disk.img copy_from_local_path: true git_url_root: "{{ lookup('env', 'WORKSPACE') }}" - name: "Check if openstacksdk is cloned" diff --git a/releasenotes/notes/generalise-use_cirros-be75f2c5452491a1.yaml b/releasenotes/notes/generalise-use_cirros-be75f2c5452491a1.yaml new file mode 100644 index 000000000..77571ad0a --- /dev/null +++ b/releasenotes/notes/generalise-use_cirros-be75f2c5452491a1.yaml @@ -0,0 +1,7 @@ +--- +deprecations: + - | + `use_cirros` and `cirros_deploy_image_upstream_url` have been deprecated in + favour of `download_custom_deploy_image` and + `custom_deploy_image_upstream_url` respectively, to better reflect their + OS-agnositic nature. The old variables will be removed in a future release. diff --git a/scripts/test-bifrost.sh b/scripts/test-bifrost.sh index 32e089104..6ee1ecf0c 100755 --- a/scripts/test-bifrost.sh +++ b/scripts/test-bifrost.sh @@ -32,7 +32,7 @@ USE_VMEDIA=${USE_VMEDIA:-false} VM_DOMAIN_TYPE=qemu export VM_DISK_CACHE="unsafe" TEST_VM_NUM_NODES=1 -USE_CIRROS=true +DOWNLOAD_CUSTOM_DEPLOY_IMAGE=true TESTING_USER=cirros TEST_PLAYBOOK="test-bifrost.yaml" USE_INSPECTOR=true @@ -74,7 +74,7 @@ if which setenforce &> /dev/null; then sudo setenforce Enforcing fi -if [ ${USE_CIRROS} = "true" ] && [ ! -f "$HOME/.ssh/id_ecdsa.pub" ]; then +if [ ${DOWNLOAD_CUSTOM_DEPLOY_IMAGE} = "true" ] && [ ! -f "$HOME/.ssh/id_ecdsa.pub" ]; then # CentOS/RHEL 8 and 9, as well as Fedora, do not work with the RSA key # that the Cirros' SSH server uses. Generate an ECDSA key pair instead. ssh-keygen -t ECDSA -f "$HOME/.ssh/id_ecdsa" -N "" @@ -98,7 +98,7 @@ if [ ${USE_DHCP} = "true" ]; then WRITE_INTERFACES_FILE=false CLOUD_CONFIG+=" -e dhcp_provider=none" elif [ ${BUILD_IMAGE} = "true" ]; then - USE_CIRROS=false + DOWNLOAD_CUSTOM_DEPLOY_IMAGE=false TESTING_USER=root VM_MEMORY_SIZE="4096" ENABLE_INSPECTOR=false @@ -111,7 +111,7 @@ elif [ ${ENABLE_KEYSTONE} = "true" ]; then CLOUD_CONFIG+=" -e cloud_name=bifrost" fi -REDEPLOY_NODES=$USE_CIRROS +REDEPLOY_NODES=$DOWNLOAD_CUSTOM_DEPLOY_IMAGE if [[ -n "$BOOT_MODE" ]]; then CLOUD_CONFIG+=" -e default_boot_mode=$BOOT_MODE" @@ -188,7 +188,7 @@ ${ANSIBLE} -vvvv \ -i inventory/bifrost_inventory.py \ -i inventory/target \ ${TEST_PLAYBOOK} \ - -e use_cirros=${USE_CIRROS} \ + -e download_custom_deploy_image=${DOWNLOAD_CUSTOM_DEPLOY_IMAGE} \ -e use_tinyipa=true \ -e testing_user=${TESTING_USER} \ -e test_vm_num_nodes=${TEST_VM_NUM_NODES} \ diff --git a/tools/vagrant_dev_env/vagrant.yml b/tools/vagrant_dev_env/vagrant.yml index bda7b2185..457444b2e 100644 --- a/tools/vagrant_dev_env/vagrant.yml +++ b/tools/vagrant_dev_env/vagrant.yml @@ -91,7 +91,7 @@ become: yes - name: Install Bifrost - command: ${VENV}/bin/ansible-playbook -vvvv -i inventory/target install.yaml -e network_interface={{network_interface}} -e ansible_python_interpreter="/usr/bin/python3" -e download_ipa=true -e use_cirros=true + command: ${VENV}/bin/ansible-playbook -vvvv -i inventory/target install.yaml -e network_interface={{network_interface}} -e ansible_python_interpreter="/usr/bin/python3" -e download_ipa=true -e download_custom_deploy_image=true environment: PATH: "{{ansible_env.HOME}}/.local/bin:{{ansible_env.PATH}}" VENV: "/opt/stack/bifrost"