Skip to content

Commit 925d1de

Browse files
authored
Merge pull request #23 from stackhpc/dib-backports
Backport all overcloud DIB patches
2 parents c3dbc64 + 86c8141 commit 925d1de

File tree

7 files changed

+305
-32
lines changed

7 files changed

+305
-32
lines changed
Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
11
---
2-
# Build and install a overcloud host disk image for the seed host's ironic
2+
# Build and install overcloud host disk images for the seed host's ironic
33
# service.
44

5-
- name: Ensure overcloud host disk image is built and installed
5+
- name: Ensure overcloud host disk images are built and installed
66
hosts: seed
77
tags:
88
- overcloud-host-image-build
99
vars:
10-
overcloud_host_image_name: "deployment_image"
11-
overcloud_host_disk_images:
12-
- "{{ overcloud_host_image_name }}.qcow2"
1310
overcloud_host_image_force_rebuild: False
1411
tasks:
1512
- block:
16-
- name: Ensure overcloud host disk image is built
13+
- name: Validate overcloud host disk image configuration
14+
assert:
15+
that:
16+
- overcloud_dib_host_images is sequence
17+
- overcloud_dib_host_images | selectattr('name', 'undefined') | list | length == 0
18+
- overcloud_dib_host_images | selectattr('elements', 'undefined') | list | length == 0
19+
msg: "overcloud_dib_host_images set to invalid value"
20+
21+
- name: Ensure overcloud host disk images are built
1722
include_role:
1823
name: stackhpc.os-images
1924
vars:
@@ -22,30 +27,18 @@
2227
os_images_upper_constraints_file: "{{ overcloud_dib_upper_constraints_file }}"
2328
os_images_cache: "{{ image_cache_path }}"
2429
os_images_common: ""
25-
os_images_list:
26-
- name: "{{ overcloud_host_image_name }}"
27-
elements: "{{ overcloud_dib_elements }}"
28-
env: "{{ overcloud_dib_env_vars }}"
29-
packages: "{{ overcloud_dib_packages }}"
30-
type: qcow2
30+
os_images_list: "{{ overcloud_dib_host_images }}"
31+
os_images_git_elements: "{{ overcloud_dib_git_elements }}"
3132
os_images_upload: False
3233
os_images_force_rebuild: "{{ overcloud_host_image_force_rebuild }}"
3334

34-
- name: Ensure overcloud host disk image is copied onto seed
35+
- name: Copy overcloud host disk images into /httpboot
3536
copy:
36-
src: "{{ image_cache_path }}/{{ overcloud_host_image_name }}/{{ item }}"
37-
dest: "/etc/kolla/bifrost/{{ item }}"
37+
src: "{{ image_cache_path }}/{{ image.name }}/{{ image.name }}.{{ image.type | default('qcow2') }}"
38+
dest: "/var/lib/docker/volumes/bifrost_httpboot/_data/{{ image.name }}.{{ image.type | default('qcow2') }}"
3839
remote_src: True
39-
with_items: "{{ overcloud_host_disk_images }}"
40+
with_items: "{{ overcloud_dib_host_images }}"
41+
loop_control:
42+
loop_var: image
4043
become: True
41-
42-
- name: Copy overcloud host disk image into /httpboot
43-
command: >
44-
docker exec bifrost_deploy
45-
bash -c 'ansible -vvvv target
46-
-i /bifrost/playbooks/inventory/target
47-
-m copy
48-
-a "src=/etc/bifrost/{{ item }} dest=/httpboot/{{ item }}"
49-
-e "ansible_python_interpreter=/var/lib/kolla/venv/bin/python"'
50-
with_items: "{{ overcloud_host_disk_images }}"
5144
when: overcloud_dib_build_host_images | bool

doc/source/configuration/reference/bifrost.rst

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ For example, to install Bifrost from a custom git repository:
3939
Overcloud root disk image configuration
4040
=======================================
4141

42+
.. note::
43+
44+
This configuration only applies when ``overcloud_dib_build_host_images``
45+
(set in ``${KAYOBE_CONFIG_PATH}/overcloud-dib.yml``) is not changed to true.
46+
4247
Bifrost uses Diskimage builder (DIB) to build a root disk image that is
4348
deployed to overcloud hosts when they are provisioned. The following options
4449
configure how this image is built. Consult the
@@ -179,6 +184,8 @@ Rather than needing to write a custom DIB element, we can use the
179184
kolla_bifrost_dib_packages:
180185
- "biosdevname"
181186
187+
.. _configuration-bifrost-image-deployment-config:
188+
182189
Disk image deployment configuration
183190
===================================
184191

@@ -189,11 +196,10 @@ The name of the root disk image to deploy can be configured via the
189196
Kayobe inventory. This can be used to provision different images across the
190197
overcloud.
191198

192-
.. note::
193-
194-
Support for building multiple disk images is not yet available. Images can
195-
be manually renamed before changing the Kayobe configuration to build a
196-
different image.
199+
While only a single disk image can be built with Bifrost, starting from the
200+
Yoga 12.0.0 release, Kayobe supports building multiple disk images directly
201+
through Diskimage builder. Consult the :ref:`overcloud host disk image build
202+
documentation <overcloud-dib>` for more details.
197203

198204
Ironic configuration
199205
====================

doc/source/configuration/reference/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ options.
1818
kolla
1919
kolla-ansible
2020
bifrost
21+
overcloud-dib
2122
ironic-python-agent
2223
docker-registry
2324
seed-custom-containers

doc/source/configuration/reference/os-distribution.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.. _os-distribution:
2+
13
===============
24
OS Distribution
35
===============
Lines changed: 242 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,242 @@
1+
.. _overcloud-dib:
2+
3+
===============================
4+
Overcloud host disk image build
5+
===============================
6+
7+
This section covers configuration for building overcloud host disk images with
8+
Diskimage builder (DIB), which is available from the Yoga 12.0.0 release. This
9+
configuration is applied in ``${KAYOBE_CONFIG_PATH}/overcloud-dib.yml``.
10+
11+
Enabling host disk image build
12+
==============================
13+
14+
From the Yoga release, disk images for overcloud hosts can be built directly
15+
using Diskimage builder rather than through Bifrost. This is enabled with the
16+
following option:
17+
18+
``overcloud_dib_build_host_images``
19+
Whether to build host disk images with DIB directly instead of through
20+
Bifrost. Setting it to true disables Bifrost image build and allows images
21+
to be built with the ``kayobe overcloud host image build`` command. Default
22+
value is false. This will change in a future release.
23+
24+
With this option enabled, Bifrost will be configured to stop building a root
25+
disk image. This will become the default behaviour in a future release.
26+
27+
Overcloud root disk image configuration
28+
=======================================
29+
30+
Kayobe uses Diskimage builder (DIB) to build root disk images that are deployed
31+
to overcloud hosts when they are provisioned. The following options configure
32+
how these images are built. Consult the
33+
:diskimage-builder-doc:`Diskimage-builder documentation <>` for further
34+
information on building disk images.
35+
36+
The default configuration builds a whole disk (partitioned) image using the
37+
selected :ref:`OS distribution <os-distribution>` (CentOS Stream 8 by default)
38+
with serial console enabled, and SELinux disabled if CentOS Stream is used.
39+
`Cloud-init <https://cloudinit.readthedocs.io/en/latest/>`__ is used to process
40+
the configuration drive built by Bifrost during provisioning.
41+
42+
``overcloud_dib_host_images``
43+
List of overcloud host disk images to build. Each element is a dict
44+
defining an image in a format accepted by the `stackhpc.os-images
45+
<https://galaxy.ansible.com/stackhpc/os-images>`__ role. Default is to
46+
build an image named ``deployment_image`` configured with the
47+
``overcloud_dib_*`` variables defined below: ``{"name": "deployment_image",
48+
"elements": "{{ overcloud_dib_elements }}", "env": "{{
49+
overcloud_dib_env_vars }}", "packages": "{{ overcloud_dib_packages }}"}``.
50+
``overcloud_dib_os_element``
51+
DIB base OS element. Default is ``{{ os_distribution }}``.
52+
``overcloud_dib_os_release``
53+
DIB image OS release. Default is ``{{ os_release }}``.
54+
``overcloud_dib_elements_default``
55+
List of default DIB elements. Default is ``["centos",
56+
"cloud-init-datasources", "disable-selinux", "enable-serial-console",
57+
"vm"]`` when ``overcloud_dib_os_element`` is ``centos``, or ``["ubuntu",
58+
"cloud-init-datasources", "enable-serial-console", "vm"]`` when
59+
``overcloud_dib_os_element`` is ``ubuntu``. The ``vm`` element is poorly
60+
named, and causes DIB to build a whole disk image rather than a single
61+
partition.
62+
``overcloud_dib_elements_extra``
63+
List of additional DIB elements. Default is none.
64+
``overcloud_dib_elements``
65+
List of DIB elements. Default is a combination of ``overcloud_dib_elements_default``
66+
and ``overcloud_dib_elements_extra``.
67+
``overcloud_dib_env_vars_default``
68+
DIB default environment variables. Default is
69+
``{"DIB_BOOTLOADER_DEFAULT_CMDLINE": "nofb nomodeset gfxpayload=text
70+
net.ifnames=1", "DIB_CLOUD_INIT_DATASOURCES": "ConfigDrive", "DIB_RELEASE":
71+
"{{ overcloud_dib_os_release }}"}``.
72+
``overcloud_dib_env_vars_extra``
73+
DIB additional environment variables. Default is none.
74+
``overcloud_dib_env_vars``
75+
DIB environment variables. Default is combination of
76+
``overcloud_dib_env_vars_default`` and
77+
``overcloud_dib_env_vars_extra``.
78+
``overcloud_dib_packages``
79+
List of DIB packages to install. Default is to install no extra packages.
80+
``overcloud_dib_git_elements_default``
81+
List of default git repositories containing Diskimage Builder (DIB)
82+
elements. See stackhpc.os-images role for usage. Default is empty.
83+
``overcloud_dib_git_elements_extra``
84+
List of additional git repositories containing Diskimage Builder (DIB)
85+
elements. See stackhpc.os-images role for usage. Default is empty.
86+
``overcloud_dib_git_elements``
87+
List of git repositories containing Diskimage Builder (DIB) elements. See
88+
stackhpc.os-images role for usage. Default is a combination of
89+
``overcloud_dib_git_elements_default`` and
90+
``overcloud_dib_git_elements_extra``.
91+
``overcloud_dib_upper_constraints_file``
92+
Upper constraints file for installing packages in the virtual environment
93+
used for building overcloud host disk images. Default is ``{{
94+
pip_upper_constraints_file }}``.
95+
96+
Disk images are built with the following command:
97+
98+
.. code-block:: console
99+
100+
(kayobe) $ kayobe overcloud host image build
101+
102+
It is worth noting that images will not be rebuilt if they already exist. To
103+
force rebuilding images, it is necessary to use the ``--force-rebuild``
104+
argument.
105+
106+
.. code-block:: console
107+
108+
(kayobe) $ kayobe overcloud host image build --force-rebuild
109+
110+
Example: Adding an element
111+
--------------------------
112+
113+
In the following, we extend the list of DIB elements to add the ``growpart``
114+
element:
115+
116+
.. code-block:: yaml
117+
:caption: ``dib.yml``
118+
119+
overcloud_dib_elements_extra:
120+
- "growpart"
121+
122+
Example: Building an XFS root filesystem image
123+
----------------------------------------------
124+
125+
By default, DIB will format the image as ``ext4``. In some cases it might be
126+
useful to use XFS, for example when using the ``overlay`` Docker storage driver
127+
which can reach the maximum number of hardlinks allowed by ``ext4``.
128+
129+
In DIB, we achieve this by setting the ``FS_TYPE`` environment variable to
130+
``xfs``.
131+
132+
.. code-block:: yaml
133+
:caption: ``dib.yml``
134+
135+
overcloud_dib_env_vars_extra:
136+
FS_TYPE: "xfs"
137+
138+
Example: Configuring a development user account
139+
-----------------------------------------------
140+
141+
.. warning::
142+
143+
A development user account should not be used in production.
144+
145+
When debugging a failed deployment, it can sometimes be necessary to allow
146+
access to the image via a preconfigured user account with a known password.
147+
This can be achieved via the :diskimage-builder-doc:`devuser
148+
<elements/devuser/README>` element.
149+
150+
This example shows how to add the ``devuser`` element, and configure a username
151+
and password for an account that has passwordless sudo:
152+
153+
.. code-block:: yaml
154+
:caption: ``dib.yml``
155+
156+
overcloud_dib_elements_extra:
157+
- "devuser"
158+
159+
overcloud_dib_env_vars_extra:
160+
DIB_DEV_USER_USERNAME: "devuser"
161+
DIB_DEV_USER_PASSWORD: "correct horse battery staple"
162+
DIB_DEV_USER_PWDLESS_SUDO: "yes"
163+
164+
Alternatively, the :diskimage-builder-doc:`dynamic-login element
165+
<elements/dynamic-login/README>` can be used to authorize SSH keys by appending
166+
them to the kernel arguments.
167+
168+
Example: Configuring custom DIB elements
169+
----------------------------------------
170+
171+
Sometimes it is useful to use custom DIB elements that are not shipped with DIB
172+
itself. This can be done by sharing them in a git repository.
173+
174+
.. code-block:: yaml
175+
:caption: ``overcloud-dib.yml``
176+
177+
overcloud_dib_elements_extra:
178+
- "my-element"
179+
180+
overcloud_dib_git_elements:
181+
- repo: "https://git.example.com/custom-dib-elements"
182+
local: "{{ source_checkout_path }}/custom-dib-elements"
183+
version: "master"
184+
elements_path: "elements"
185+
186+
In this example the ``master`` branch of
187+
https://git.example.com/custom-dib-elements would have a top level ``elements``
188+
directory, containing a ``my-element`` directory for the element.
189+
190+
Example: Installing a package
191+
-----------------------------
192+
193+
It can be necessary to install additional packages in the root disk image.
194+
Rather than needing to write a custom DIB element, we can use the
195+
``overcloud_dib_packages`` variable. For example, to install the
196+
``biosdevname`` package:
197+
198+
.. code-block:: yaml
199+
:caption: ``dib.yml``
200+
201+
overcloud_dib_packages:
202+
- "biosdevname"
203+
204+
Example: Building multiple images
205+
---------------------------------
206+
207+
It can be necessary to build multiple images to support the various types of
208+
hardware present in a deployment or the different functions performed by
209+
overcloud hosts. This can be configured with the ``overcloud_dib_host_images``
210+
variable, using a format accepted by the `stackhpc.os-images
211+
<https://galaxy.ansible.com/stackhpc/os-images>`__ role. Note that image names
212+
should not include the file extension. For example, to build a second image
213+
with a development user account and the ``biosdevname`` package:
214+
215+
.. code-block:: yaml
216+
:caption: ``dib.yml``
217+
218+
overcloud_dib_host_images:
219+
- name: "deployment_image"
220+
elements: "{{ overcloud_dib_elements }}"
221+
env: "{{ overcloud_dib_env_vars }}"
222+
packages: "{{ overcloud_dib_packages }}"
223+
- name: "debug_deployment_image"
224+
elements: "{{ overcloud_dib_elements + ['devuser'] }}"
225+
env: "{{ overcloud_dib_env_vars | combine(devuser_env_vars) }}"
226+
packages: "{{ overcloud_dib_packages + ['biosdevname'] }}"
227+
228+
devuser_env_vars:
229+
DIB_DEV_USER_USERNAME: "devuser"
230+
DIB_DEV_USER_PASSWORD: "correct horse battery staple"
231+
DIB_DEV_USER_PWDLESS_SUDO: "yes"
232+
233+
Running the ``kayobe overcloud host image build`` command with this
234+
configuration will create two images: ``deployment_image.qcow2`` and
235+
``debug_deployment_image.qcow2``.
236+
237+
Disk image deployment configuration
238+
===================================
239+
240+
See :ref:`disk image deployment configuration in
241+
Bifrost<configuration-bifrost-image-deployment-config>` for how to configure
242+
the root disk image to be used to provision each host.

0 commit comments

Comments
 (0)