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.
This commit is contained in:
Mark Goddard 2017-08-15 14:54:23 +00:00
parent 20a8436d0f
commit ebb81e49f1
9 changed files with 146 additions and 0 deletions

View File

@ -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.

View File

@ -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 }}"

View File

@ -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:

View File

@ -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 }}"

View File

@ -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 }}"

View File

@ -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 <https://tarballs.openstack.org/ironic-python-agent>`_ 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)
-------------------------------------

View File

@ -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.

View File

@ -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."""

View File

@ -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',