From 461b941329df9b2264cf64acd0dc3ce1e16e9b0a Mon Sep 17 00:00:00 2001
From: Pierre Riteau <pierre@stackhpc.com>
Date: Wed, 23 Oct 2019 22:13:02 +0200
Subject: [PATCH] Add new variables for customising the deployment image in
 Bifrost

Add new variables, ``kolla_bifrost_dib_elements_extra`` and
``kolla_bifrost_dib_env_vars_extra``, in
``${KAYOBE_CONFIG_PATH}/bifrost.yml`` for setting additional
``diskimage-builder`` elements and environment variables for the disk
image generated by Bifrost. Default elements and environment variables
are now respectively defined by ``kolla_bifrost_dib_elements_default``
and ``kolla_bifrost_dib_env_vars_default``.

Change-Id: I22ab15c42d8db772f1a64f325f9371860491ccfb
---
 ansible/group_vars/all/bifrost                | 20 +++++++++++++++----
 etc/kayobe/bifrost.yml                        | 12 +++++++++++
 .../bifrost-dib-extra-c4eac903986ec700.yaml   | 19 ++++++++++++++++++
 3 files changed, 47 insertions(+), 4 deletions(-)
 create mode 100644 releasenotes/notes/bifrost-dib-extra-c4eac903986ec700.yaml

diff --git a/ansible/group_vars/all/bifrost b/ansible/group_vars/all/bifrost
index 8d0be450c..ce2fa2df2 100644
--- a/ansible/group_vars/all/bifrost
+++ b/ansible/group_vars/all/bifrost
@@ -20,19 +20,31 @@ kolla_bifrost_dib_os_element: "centos7"
 # DIB image OS release.
 kolla_bifrost_dib_os_release: "GenericCloud"
 
-# List of DIB elements.
-kolla_bifrost_dib_elements:
+# List of default DIB elements.
+kolla_bifrost_dib_elements_default:
   - "disable-selinux"
   - "enable-serial-console"
   - "vm"
 
+# List of additional DIB elements.
+kolla_bifrost_dib_elements_extra: []
+
+# List of all DIB elements.
+kolla_bifrost_dib_elements: "{{ kolla_bifrost_dib_elements_default + kolla_bifrost_dib_elements_extra }}"
+
 # DIB init element.
 kolla_bifrost_dib_init_element: "cloud-init-datasources"
 
-# DIB environment variables.
-kolla_bifrost_dib_env_vars:
+# DIB default environment variables.
+kolla_bifrost_dib_env_vars_default:
   DIB_CLOUD_INIT_DATASOURCES: "ConfigDrive"
 
+# DIB additional environment variables.
+kolla_bifrost_dib_env_vars_extra: {}
+
+# DIB environment variables.
+kolla_bifrost_dib_env_vars: "{{ kolla_bifrost_dib_env_vars_default | combine(kolla_bifrost_dib_env_vars_extra) }}"
+
 # List of DIB packages to install.
 kolla_bifrost_dib_packages: []
 
diff --git a/etc/kayobe/bifrost.yml b/etc/kayobe/bifrost.yml
index 078a6ced6..60254d2d2 100644
--- a/etc/kayobe/bifrost.yml
+++ b/etc/kayobe/bifrost.yml
@@ -20,12 +20,24 @@
 # DIB image OS release.
 #kolla_bifrost_dib_os_release:
 
+# List of default DIB elements.
+#kolla_bifrost_dib_elements_default:
+
+# List of additional DIB elements.
+#kolla_bifrost_dib_elements_extra:
+
 # List of DIB elements.
 #kolla_bifrost_dib_elements:
 
 # DIB init element.
 #kolla_bifrost_dib_init_element:
 
+# DIB default environment variables.
+#kolla_bifrost_dib_env_vars_default:
+
+# DIB additional environment variables.
+#kolla_bifrost_dib_env_vars_extra:
+
 # DIB environment variables.
 #kolla_bifrost_dib_env_vars:
 
diff --git a/releasenotes/notes/bifrost-dib-extra-c4eac903986ec700.yaml b/releasenotes/notes/bifrost-dib-extra-c4eac903986ec700.yaml
new file mode 100644
index 000000000..04e2746b9
--- /dev/null
+++ b/releasenotes/notes/bifrost-dib-extra-c4eac903986ec700.yaml
@@ -0,0 +1,19 @@
+---
+features:
+  - |
+    Adds new variables, ``kolla_bifrost_dib_elements_extra`` and
+    ``kolla_bifrost_dib_env_vars_extra``, in
+    ``${KAYOBE_CONFIG_PATH}/bifrost.yml`` for setting additional
+    ``diskimage-builder`` elements and environment variables for the disk image
+    generated by Bifrost. Default elements and environment variables are now
+    respectively defined by ``kolla_bifrost_dib_elements_default`` and
+    ``kolla_bifrost_dib_env_vars_default``.
+upgrade:
+  - |
+    It is now possible to set additional ``diskimage-builder`` elements and
+    environment variables for the disk image generated by Bifrost, while
+    keeping defaults set by Kayobe. If your configuration overrides
+    ``kolla_bifrost_dib_elements`` or ``kolla_bifrost_dib_env_vars`` while
+    still including default values set in ``ansible/group_vars/all/bifrost``,
+    you can move your additions to ``kolla_bifrost_dib_elements_extra`` and
+    ``kolla_bifrost_dib_env_vars_extra`` instead.