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