From ebb81e49f1314f0cc1b6cec47507bf0a4074f76d Mon Sep 17 00:00:00 2001 From: Mark Goddard Date: Tue, 15 Aug 2017 14:54:23 +0000 Subject: [PATCH] Add command to build IPA deployment images for the seed The CLI command is: kayobe seed deployment image build This command will build Ironic Python Agent (IPA) kernel and ramdisk images using the Diskimage Builder (DIB) ironic-agent element. The built images will be copied to the appropriate location in the bifrost_deploy container on the seed. This allows us to build a customised image with site- or hardware- specific extensions. --- ansible/group_vars/all/ipa | 36 ++++++++++++++ ansible/kolla-bifrost.yml | 1 + ansible/roles/kolla-bifrost/defaults/main.yml | 3 ++ .../kolla-bifrost/templates/bifrost.yml.j2 | 3 ++ ansible/seed-ipa-build.yml | 49 +++++++++++++++++++ doc/source/deployment.rst | 17 +++++++ etc/kayobe/ipa.yml | 27 ++++++++++ kayobe/cli/commands.py | 9 ++++ setup.py | 1 + 9 files changed, 146 insertions(+) create mode 100644 ansible/seed-ipa-build.yml diff --git a/ansible/group_vars/all/ipa b/ansible/group_vars/all/ipa index cfb50419c..d4513e435 100644 --- a/ansible/group_vars/all/ipa +++ b/ansible/group_vars/all/ipa @@ -20,6 +20,42 @@ ipa_build_upper_constraints_file_url: # to upper version constraint. ipa_build_custom_upper_constraints: [] +# List of default Diskimage Builder (DIB) elements to use when building IPA +# images. +ipa_build_dib_elements_default: + - centos7 + - enable-serial-console + - ironic-agent + +# List of additional Diskimage Builder (DIB) elements to use when building IPA +# images. +ipa_build_dib_elements_extra: [] + +# List of Diskimage Builder (DIB) elements to use when building IPA images. +ipa_build_dib_elements: > + {{ ipa_build_dib_elements_default + + ipa_build_dib_elements_extra }} + +# Dictionary of default environment variables to provide to Diskimage Builder +# (DIB) during IPA image build. +ipa_build_dib_env_default: + DIB_REPOLOCATION: "{{ ipa_build_source_url }}" + DIB_REPOREF: "{{ ipa_build_source_version }}" + +# Dictionary of additional environment variables to provide to Diskimage +# Builder (DIB) during IPA image build. +ipa_build_dib_env_extra: {} + +# Dictionary of environment variables to provide to Diskimage Builder (DIB) +# during IPA image build. +ipa_build_dib_env: > + {{ ipa_build_dib_env_default | + combine(ipa_build_dib_env_extra) }} + +# List of git repositories containing Diskimage Builder (DIB) elements. See +# stackhpc.os-images role for usage. +ipa_build_dib_git_elements: [] + ############################################################################### # Ironic Python Agent (IPA) images configuration. diff --git a/ansible/kolla-bifrost.yml b/ansible/kolla-bifrost.yml index 88ae930b6..dc0ff05c4 100644 --- a/ansible/kolla-bifrost.yml +++ b/ansible/kolla-bifrost.yml @@ -34,3 +34,4 @@ kolla_bifrost_dnsmasq_router: "{{ provision_oc_net_name | net_gateway }}" kolla_bifrost_dnsmasq_dns_servers: "{{ resolv_nameservers | default([]) }}" kolla_bifrost_domain: "{{ resolv_domain | default }}" + kolla_bifrost_download_ipa: "{{ not ipa_build_images | bool }}" diff --git a/ansible/roles/kolla-bifrost/defaults/main.yml b/ansible/roles/kolla-bifrost/defaults/main.yml index 2ac0cc855..f1e34e55f 100644 --- a/ansible/roles/kolla-bifrost/defaults/main.yml +++ b/ansible/roles/kolla-bifrost/defaults/main.yml @@ -52,6 +52,9 @@ kolla_bifrost_inspector_port_addition: # List of extra kernel parameters for the inspector default PXE configuration. kolla_bifrost_inspector_extra_kernel_options: +# Whether to download the Ironic Python Agent (IPA) images. +kolla_bifrost_download_ipa: true + # URL of Ironic Python Agent (IPA) kernel image. kolla_bifrost_ipa_kernel_upstream_url: diff --git a/ansible/roles/kolla-bifrost/templates/bifrost.yml.j2 b/ansible/roles/kolla-bifrost/templates/bifrost.yml.j2 index b870eab52..aa253199f 100644 --- a/ansible/roles/kolla-bifrost/templates/bifrost.yml.j2 +++ b/ansible/roles/kolla-bifrost/templates/bifrost.yml.j2 @@ -43,6 +43,9 @@ inspector_port_addition: "{{ kolla_bifrost_inspector_port_addition }}" inspector_extra_kernel_options: "{{ kolla_bifrost_inspector_extra_kernel_options | join(' ') }}" {% endif %} +# Whether to download Ironic Python Agent (IPA) images. +download_ipa: "{{ kolla_bifrost_download_ipa }}" + {% if kolla_bifrost_ipa_kernel_upstream_url %} # URL of Ironic Python Agent (IPA) kernel image. ipa_kernel_upstream_url: "{{ kolla_bifrost_ipa_kernel_upstream_url }}" diff --git a/ansible/seed-ipa-build.yml b/ansible/seed-ipa-build.yml new file mode 100644 index 000000000..b50dcff2b --- /dev/null +++ b/ansible/seed-ipa-build.yml @@ -0,0 +1,49 @@ +--- +# Build and install an Ironic Python Agent (IPA) image for the seed host's +# ironic and ironic-inspector services. + +- name: Ensure Ironic Python Agent images are built and installed + hosts: seed + vars: + ipa_image_name: "ipa" + ipa_images: + - "{{ ipa_image_name }}.vmlinuz" + - "{{ ipa_image_name }}.initramfs" + tasks: + - block: + - name: Ensure Ironic Python Agent images are built + include_role: + name: stackhpc.os-images + os_images_venv: "{{ virtualenv_path }}/ipa-build-dib" + os_images_cache: "{{ image_cache_path }}" + os_images_common: "" + os_images_list: + - name: "{{ ipa_image_name }}" + elements: "{{ ipa_build_dib_elements }}" + env: "{{ ipa_build_dib_env }}" + # Avoid needing to install qemu-img for qcow2 image. + type: raw + os_images_git_elements: "{{ ipa_build_dib_git_elements }}" + os_images_upload: False + + - name: Ensure Ironic Python Agent images are copied onto seed + copy: + src: "{{ image_cache_path }}/{{ ipa_image_name }}/{{ item }}" + dest: "/etc/kolla/bifrost/{{ item }}" + remote_src: True + with_items: "{{ ipa_images }}" + notify: + - Copy Ironic Python Agent images into /httpboot + become: True + when: "{{ ipa_build_images | bool }}" + + handlers: + - name: Copy Ironic Python Agent images into /httpboot + command: > + docker exec bifrost_deploy + bash -c 'source /bifrost/env-vars && + ansible -vvvv target -i /bifrost/playbooks/inventory/target + -m copy + -a "src=/etc/bifrost/{{ item }} dest=/httpboot/{{ item }}" + -e "ansible_python_interpreter=/var/lib/kolla/venv/bin/python"' + with_items: "{{ ipa_images }}" diff --git a/doc/source/deployment.rst b/doc/source/deployment.rst index b78a998c0..c2a275365 100644 --- a/doc/source/deployment.rst +++ b/doc/source/deployment.rst @@ -131,6 +131,23 @@ To deploy the seed services in containers:: After this command has completed the seed services will be active. +Building Deployment Images +-------------------------- + +.. note:: + + It is possible to use prebuilt deployment images. In this case, this step + can be skipped. + +It is possible to use prebuilt deployment images from the `OpenStack hosted +tarballs `_ or another +source. In some cases it may be necessary to build images locally either to +apply local image customisation or to use a downstream version of Ironic Python +Agent (IPA). In order to build IPA images, the ``ipa_build_images`` variable +should be set to ``True``. To build images locally:: + + (kayobe-venv) $ kayobe seed deployment image build + Accessing the Seed via SSH (Optional) ------------------------------------- diff --git a/etc/kayobe/ipa.yml b/etc/kayobe/ipa.yml index 4056afae1..176ae9836 100644 --- a/etc/kayobe/ipa.yml +++ b/etc/kayobe/ipa.yml @@ -20,6 +20,33 @@ # to upper version constraint. #ipa_build_custom_upper_constraints: +# List of default Diskimage Builder (DIB) elements to use when building IPA +# images. +#ipa_build_dib_elements_default: + +# List of additional Diskimage Builder (DIB) elements to use when building IPA +# images. +#ipa_build_dib_elements_extra: + +# List of Diskimage Builder (DIB) elements to use when building IPA images. +#ipa_build_dib_elements: + +# Dictionary of default environment variables to provide to Diskimage Builder +# (DIB) during IPA image build. +#ipa_build_dib_env_default: + +# Dictionary of additional environment variables to provide to Diskimage +# Builder (DIB) during IPA image build. +#ipa_build_dib_env_extra: + +# Dictionary of environment variables to provide to Diskimage Builder (DIB) +# during IPA image build. +#ipa_build_dib_env: + +# List of git repositories containing Diskimage Builder (DIB) elements. See +# stackhpc.os-images role for usage. +#ipa_build_dib_git_elements: + ############################################################################### # Ironic Python Agent (IPA) images configuration. diff --git a/kayobe/cli/commands.py b/kayobe/cli/commands.py index 9d50c2518..e7ea550ce 100644 --- a/kayobe/cli/commands.py +++ b/kayobe/cli/commands.py @@ -340,6 +340,15 @@ class SeedContainerImageBuild(KayobeAnsibleMixin, VaultMixin, Command): extra_vars=extra_vars) +class SeedDeploymentImageBuild(KayobeAnsibleMixin, VaultMixin, Command): + """Build the seed deployment kernel and ramdisk images.""" + + def take_action(self, parsed_args): + self.app.LOG.debug("Building seed deployment images") + playbooks = _build_playbook_list("seed-ipa-build") + self.run_kayobe_playbooks(parsed_args, playbooks) + + class OvercloudInventoryDiscover(KayobeAnsibleMixin, VaultMixin, Command): """Discover the overcloud inventory from the seed's Ironic service.""" diff --git a/setup.py b/setup.py index 8ebfaaea5..0f6000e01 100644 --- a/setup.py +++ b/setup.py @@ -71,6 +71,7 @@ setup( 'physical_network_configure = kayobe.cli.commands:PhysicalNetworkConfigure', 'playbook_run = kayobe.cli.commands:PlaybookRun', 'seed_container_image_build = kayobe.cli.commands:SeedContainerImageBuild', + 'seed_deployment_image_build = kayobe.cli.commands:SeedDeploymentImageBuild', 'seed_host_configure = kayobe.cli.commands:SeedHostConfigure', 'seed_hypervisor_host_configure = kayobe.cli.commands:SeedHypervisorHostConfigure', 'seed_service_deploy = kayobe.cli.commands:SeedServiceDeploy',