From 9c4e320dd1e94045465888227aa3a49f4ce8f39a Mon Sep 17 00:00:00 2001
From: Mark Goddard <mark@stackhpc.com>
Date: Tue, 17 Oct 2017 13:26:26 +0000
Subject: [PATCH] Add support for custom neutron and nova config files

Custom configuration files may be added in
$KAYOBE_CONFIG_PATH/kolla/config/[nova,neutron]/.
---
 ansible/group_vars/all/kolla                  |  1 +
 ansible/kolla-openstack.yml                   |  4 ++-
 .../roles/kolla-openstack/defaults/main.yml   |  9 ++++++
 .../roles/kolla-openstack/tasks/config.yml    | 29 +++++++++++++++----
 doc/source/release-notes.rst                  |  7 +++--
 5 files changed, 42 insertions(+), 8 deletions(-)

diff --git a/ansible/group_vars/all/kolla b/ansible/group_vars/all/kolla
index 468c609b..905c33ad 100644
--- a/ansible/group_vars/all/kolla
+++ b/ansible/group_vars/all/kolla
@@ -235,6 +235,7 @@ kolla_enable_glance: "yes"
 kolla_enable_haproxy: "yes"
 kolla_enable_ironic: "yes"
 kolla_enable_neutron: "yes"
+kolla_enable_nova: "yes"
 kolla_enable_magnum: "no"
 kolla_enable_murano: "no"
 kolla_enable_sahara: "no"
diff --git a/ansible/kolla-openstack.yml b/ansible/kolla-openstack.yml
index 337e32be..f00445b4 100644
--- a/ansible/kolla-openstack.yml
+++ b/ansible/kolla-openstack.yml
@@ -185,5 +185,7 @@
       kolla_extra_neutron_ml2: "{{ kolla_extra_config.neutron_ml2 | default }}"
       kolla_extra_nova: "{{ kolla_extra_config.nova | default }}"
       kolla_extra_sahara: "{{ kolla_extra_config.sahara | default }}"
-      kolla_extra_glance_path: "{{ kayobe_config_path }}/kolla/config/glance"
       kolla_extra_fluentd_output_path: "{{ kayobe_config_path }}/kolla/config/fluentd/output"
+      kolla_extra_glance_path: "{{ kayobe_config_path }}/kolla/config/glance"
+      kolla_extra_neutron_path: "{{ kayobe_config_path }}/kolla/config/neutron"
+      kolla_extra_nova_path: "{{ kayobe_config_path }}/kolla/config/nova"
diff --git a/ansible/roles/kolla-openstack/defaults/main.yml b/ansible/roles/kolla-openstack/defaults/main.yml
index 5b35e463..752699f0 100644
--- a/ansible/roles/kolla-openstack/defaults/main.yml
+++ b/ansible/roles/kolla-openstack/defaults/main.yml
@@ -18,6 +18,9 @@ kolla_enable_glance:
 # glance-registry.conf.
 kolla_extra_glance:
 
+# Path to extra Glance configuration files.
+kolla_extra_glance_path:
+
 ###############################################################################
 # Ironic configuration.
 
@@ -252,6 +255,9 @@ kolla_extra_neutron:
 # Free form extra configuration to append to ml2_conf.ini.
 kolla_extra_neutron_ml2:
 
+# Path to extra Neutron configuration files.
+kolla_extra_neutron_path:
+
 ###############################################################################
 # Nova configuration.
 
@@ -261,6 +267,9 @@ kolla_enable_nova:
 # Free form extra configuration to append to nova.conf.
 kolla_extra_nova:
 
+# Path to extra Nova configuration files.
+kolla_extra_nova_path:
+
 ###############################################################################
 # Sahara configuration.
 
diff --git a/ansible/roles/kolla-openstack/tasks/config.yml b/ansible/roles/kolla-openstack/tasks/config.yml
index b715919e..59d7c0c6 100644
--- a/ansible/roles/kolla-openstack/tasks/config.yml
+++ b/ansible/roles/kolla-openstack/tasks/config.yml
@@ -6,11 +6,12 @@
     mode: 0750
   with_items:
     - { name: fluentd/output, enabled: "{{ kolla_extra_fluentd_output_path != None }}" }
+    - { name: glance, enabled: "{{ kolla_enable_glance }}" }
     - { name: ironic, enabled: "{{ kolla_enable_ironic }}" }
     - { name: neutron, enabled: "{{ kolla_enable_neutron }}" }
+    - { name: nova, enabled: "{{ kolla_enable_nova }}" }
     - { name: swift, enabled: "{{ kolla_enable_swift }}" }
-    - { name: glance, enabled: "{{ kolla_enable_glance }}" }
-  when: "{{ item.enabled | bool }}"
+  when: item.enabled | bool
 
 - name: Ensure the Kolla OpenStack configuration files exist
   template:
@@ -29,7 +30,7 @@
     - { src: nova.conf.j2, dest: nova.conf, enabled: "{{ kolla_enable_nova }}" }
     - { src: pxelinux.default.j2, dest: ironic/pxelinux.default, enabled: "{{ kolla_enable_ironic }}" }
     - { src: sahara.conf.j2, dest: sahara.conf, enabled: "{{ kolla_enable_sahara }}" }
-  when: "{{ item.enabled | bool }}"
+  when: item.enabled | bool
 
 - name: Ensure extra glance configuration files exist
   template:
@@ -38,7 +39,7 @@
     mode: 0640
   with_fileglob:
     - "{{ kolla_extra_glance_path }}/*"
-  when: "{{ kolla_extra_glance_path != None }}"
+  when: kolla_extra_glance_path != None
 
 - name: Ensure extra fluentd output configuration files exist
   template:
@@ -47,7 +48,7 @@
     mode: 0640
   with_fileglob:
     - "{{ kolla_extra_fluentd_output_path }}/*.conf"
-  when: "{{ kolla_extra_fluentd_output_path != None }}"
+  when: kolla_extra_fluentd_output_path != None
 
 - name: Ensure the ironic inspector kernel and ramdisk are downloaded
   get_url:
@@ -72,3 +73,21 @@
   when:
     - kolla_enable_ironic | bool
     - item.path != None
+
+- name: Ensure extra neutron configuration files exist
+  template:
+    src: "{{ item }}"
+    dest: "{{ kolla_node_custom_config_path }}/neutron/{{ item | basename }}"
+    mode: 0640
+  with_fileglob:
+    - "{{ kolla_extra_neutron_path }}/*"
+  when: kolla_extra_neutron_path != None
+
+- name: Ensure extra nova configuration files exist
+  template:
+    src: "{{ item }}"
+    dest: "{{ kolla_node_custom_config_path }}/nova/{{ item | basename }}"
+    mode: 0640
+  with_fileglob:
+    - "{{ kolla_extra_nova_path }}/*"
+  when: kolla_extra_nova_path != None
diff --git a/doc/source/release-notes.rst b/doc/source/release-notes.rst
index bf91f98d..9ba56294 100644
--- a/doc/source/release-notes.rst
+++ b/doc/source/release-notes.rst
@@ -11,8 +11,11 @@ Features
 * Adds ``--interface-limit`` and ``--interface-description-limit`` arguments to
   the ``kayobe physical network configure`` command.  These arguments allow
   configuration to be limited to a subset of switch interfaces.
-* Adds a ``display`` argument to ``kayobe physical network configure`` command.
-  This will output the candidate switch configuration without applying it.
+* Adds a ``--display`` argument to ``kayobe physical network configure``
+  command.  This will output the candidate switch configuration without
+  applying it.
+* Adds support for custom neutron and nova configuration files in
+  ``$KAYOBE_CONFIG_PATH/kolla/config/[neutron,nova]``.
 
 Upgrade Notes
 -------------
-- 
GitLab