Add build_diskimage_environment role variable

This adds a role variable to configure the diskimage-builder environment.
This allows users a choice of using the Ansible "environment" argument,
or using a variable.  The variable may be particularly useful since it
allows full configuration of the role from a Zuul job definition.

Change-Id: I68542f13454b4f2e2e9bb8d356feefddba23d8f2
This commit is contained in:
James E. Blair 2024-08-13 09:39:32 -07:00 committed by Benjamin Schanzel
parent dded8d0853
commit c5c2eae9c1
No known key found for this signature in database
4 changed files with 16 additions and 2 deletions

View File

@ -1,7 +1,12 @@
Role for building images using diskimage-builder.
Diskimage-builder and diskimage elements can be configured by passing
corresponding settings as environment variables to this role.
corresponding settings as environment variables to this role, or using
the ``build_diskimage_environment`` variable.
By default the `build-disk-image` command does not print its output to stdout,
but only to a log file in the configured log directory. To additionally log to
stdout, set `DIB_QUIET: 0` in `build_diskimage_environment`.
Example:
@ -37,6 +42,13 @@ Example:
List of elements that should be used when creating the disk image.
.. zuul:rolevar:: build_diskimage_environment
:type: dict
Environment variables for the diskimage builder command may be
supplied using this variable (or by directly using the Ansible
``environment`` argument).
.. zuul:rolevar:: build_diskimage_image_root
:default: "{{ ansible_user_dir }}/dib-images"

View File

@ -11,3 +11,4 @@ build_diskimage_image_root: "{{ ansible_user_dir }}/dib-images"
build_diskimage_logs_dir: "{{ ansible_user_dir }}/zuul-output/logs"
build_diskimage_retry_limit: 0
build_diskimage_retry_delay: 120
build_diskimage_environment: {}

View File

@ -12,6 +12,7 @@
{{ build_diskimage_elements | mandatory | join(' ') }}
args:
chdir: "{{ build_diskimage_image_root }}"
environment: "{{ build_diskimage_environment }}"
register: build_diskimage_result
until: build_diskimage_result is not failed
retries: "{{ build_diskimage_retry_limit }}"

View File

@ -5,7 +5,7 @@
build_diskimage_image_name: foo-ubuntu-image
build_diskimage_formats: ["qcow2"]
build_diskimage_elements: ["vm", "ubuntu"]
environment:
build_diskimage_environment:
DIB_RELEASE: "noble"
tasks:
- name: Gather image file info