From c72dd2fd7b62d6a3422504e1decfcc024a67e8bb Mon Sep 17 00:00:00 2001 From: Mark Goddard Date: Thu, 22 Apr 2021 10:28:19 +0100 Subject: [PATCH] Install DIB dependencies in bifrost-ironic-install role This provides a cleaner separation between installation and image creation. This allows Kolla to install all package dependencies at container image build time rather than when using the container image to build disk images. Story: 2008839 Task: 42346 Change-Id: I5be8b355b92f0d9d907c743b522982f6de0398c1 --- playbooks/inventory/group_vars/localhost | 2 +- playbooks/inventory/group_vars/target | 2 +- .../bifrost-create-dib-image/tasks/main.yml | 18 ------------------ .../bifrost-ironic-install/defaults/main.yml | 6 ++++-- .../bifrost-ironic-install/tasks/install.yml | 6 ++++++ .../vars/main.yml | 1 + ...move-dib-deps-install-8a8aafc060461dc0.yaml | 7 +++++++ 7 files changed, 20 insertions(+), 22 deletions(-) rename playbooks/roles/{bifrost-create-dib-image => bifrost-ironic-install}/vars/main.yml (88%) create mode 100644 releasenotes/notes/move-dib-deps-install-8a8aafc060461dc0.yaml diff --git a/playbooks/inventory/group_vars/localhost b/playbooks/inventory/group_vars/localhost index 546432503..94ba9e80e 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: true +create_image_via_dib: "{{ not 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 546432503..94ba9e80e 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: true +create_image_via_dib: "{{ not 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-create-dib-image/tasks/main.yml b/playbooks/roles/bifrost-create-dib-image/tasks/main.yml index 2008ce85f..e12c50019 100644 --- a/playbooks/roles/bifrost-create-dib-image/tasks/main.yml +++ b/playbooks/roles/bifrost-create-dib-image/tasks/main.yml @@ -13,11 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. --- -- name: Ensure required packages are installed - package: - name: "{{ dib_host_required_packages }}" - state: present - when: not skip_package_install | bool # If attempting to utilize a base Ubuntu image, diskimage-builder # is the recommended, and default path. - name: "Test if image is present" @@ -186,19 +181,6 @@ {{ dib_packages_arg|default('') }} {{ dib_os_element }} {{ dib_elements|default('') }} -- name: "Update package cache on Debian and Ubuntu" - apt: - update_cache: yes - when: ansible_os_family == 'Debian' -- name: Install debootstrap if building a Debian image - package: - name: debootstrap - state: present - when: - - not test_image_present.stat.exists - - not test_image_dib_present.stat.exists - - not test_image_initramfs_present.stat.exists - - ("debian" in dib_os_element or "ubuntu" in dib_os_element) - name: "Initiate image build" command: disk-image-create {{ dib_arglist }} environment: "{{ dib_env_vars_final | combine(bifrost_venv_env) }}" diff --git a/playbooks/roles/bifrost-ironic-install/defaults/main.yml b/playbooks/roles/bifrost-ironic-install/defaults/main.yml index 240f79885..0650c5974 100644 --- a/playbooks/roles/bifrost-ironic-install/defaults/main.yml +++ b/playbooks/roles/bifrost-ironic-install/defaults/main.yml @@ -21,10 +21,12 @@ 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: true +create_image_via_dib: "{{ not use_cirros | default(false) | bool }}" +create_ipa_image: false dib_image_type: vm +dib_os_element: "debian" # Setting to install diskimage-builder -install_dib: "{{ create_image_via_dib }}" +install_dib: "{{ create_image_via_dib | bool or create_ipa_image | bool }}" ironic_debug: true # If testing is true, then the environment is setup for using libvirt # virtual machines for the hardware instead of real hardware. diff --git a/playbooks/roles/bifrost-ironic-install/tasks/install.yml b/playbooks/roles/bifrost-ironic-install/tasks/install.yml index 07e4d8f6c..3a05828d6 100644 --- a/playbooks/roles/bifrost-ironic-install/tasks/install.yml +++ b/playbooks/roles/bifrost-ironic-install/tasks/install.yml @@ -51,6 +51,12 @@ source_install: true when: install_dib | bool +- name: Ensure required packages are installed + package: + name: "{{ dib_host_required_packages | select | list }}" + state: present + when: install_dib | bool + - name: "sushy - Install" include_role: name: bifrost-pip-install diff --git a/playbooks/roles/bifrost-create-dib-image/vars/main.yml b/playbooks/roles/bifrost-ironic-install/vars/main.yml similarity index 88% rename from playbooks/roles/bifrost-create-dib-image/vars/main.yml rename to playbooks/roles/bifrost-ironic-install/vars/main.yml index 1c70b7d91..d47f08a5b 100644 --- a/playbooks/roles/bifrost-create-dib-image/vars/main.yml +++ b/playbooks/roles/bifrost-ironic-install/vars/main.yml @@ -18,3 +18,4 @@ dib_host_required_packages: - gdisk - "squashfs{% if ansible_os_family != 'Suse' %}-tools{% endif %}" - xfsprogs + - "{% if 'debian' in dib_os_element or 'ubuntu' in dib_os_element %}debootstrap{% endif %}" diff --git a/releasenotes/notes/move-dib-deps-install-8a8aafc060461dc0.yaml b/releasenotes/notes/move-dib-deps-install-8a8aafc060461dc0.yaml new file mode 100644 index 000000000..e132dabe7 --- /dev/null +++ b/releasenotes/notes/move-dib-deps-install-8a8aafc060461dc0.yaml @@ -0,0 +1,7 @@ +--- +upgrade: + - | + Moves installation of package dependencies for Diskimage Builder (DIB) from + the ``bifrost-create-dib-image`` role to the ``bifrost-install-ironic`` + role. This provides a cleaner separation between installation and image + creation.