From aebb16fff9f33727aa9ce49120a1c6384544bfdc Mon Sep 17 00:00:00 2001
From: rthallisey <rhallise@redhat.com>
Date: Fri, 28 Aug 2015 18:42:18 -0400
Subject: [PATCH] Replace config-external with a JSON file for Nova

Change-Id: I38c545484a7b1f3906d844eb3a7486e11c4b276a
Partially-Implements: blueprint replace-config-external
---
 ansible/roles/nova/tasks/bootstrap.yml        |  2 +-
 ansible/roles/nova/tasks/config.yml           | 35 +++++++++++++++++++
 ansible/roles/nova/tasks/start.yml            | 14 ++++----
 ansible/roles/nova/templates/nova-api.json.j2 | 11 ++++++
 .../roles/nova/templates/nova-compute.json.j2 | 11 ++++++
 .../nova/templates/nova-conductor.json.j2     | 11 ++++++
 .../nova/templates/nova-consoleauth.json.j2   | 11 ++++++
 .../roles/nova/templates/nova-libvirt.json.j2 |  4 +++
 .../roles/nova/templates/nova-network.json.j2 | 11 ++++++
 .../nova/templates/nova-novncproxy.json.j2    | 11 ++++++
 .../nova/templates/nova-scheduler.json.j2     | 11 ++++++
 docker/nova/nova-api/start.sh                 | 11 +++---
 docker/nova/nova-compute/start.sh             | 11 +++---
 docker/nova/nova-conductor/start.sh           | 11 +++---
 docker/nova/nova-consoleauth/start.sh         | 11 +++---
 docker/nova/nova-libvirt/start.sh             | 11 +++---
 docker/nova/nova-network/start.sh             | 10 +++---
 docker/nova/nova-novncproxy/start.sh          | 11 +++---
 docker/nova/nova-scheduler/start.sh           | 11 +++---
 19 files changed, 163 insertions(+), 56 deletions(-)
 create mode 100644 ansible/roles/nova/templates/nova-api.json.j2
 create mode 100644 ansible/roles/nova/templates/nova-compute.json.j2
 create mode 100644 ansible/roles/nova/templates/nova-conductor.json.j2
 create mode 100644 ansible/roles/nova/templates/nova-consoleauth.json.j2
 create mode 100644 ansible/roles/nova/templates/nova-libvirt.json.j2
 create mode 100644 ansible/roles/nova/templates/nova-network.json.j2
 create mode 100644 ansible/roles/nova/templates/nova-novncproxy.json.j2
 create mode 100644 ansible/roles/nova/templates/nova-scheduler.json.j2

diff --git a/ansible/roles/nova/tasks/bootstrap.yml b/ansible/roles/nova/tasks/bootstrap.yml
index c41fcf449..c06c011d0 100644
--- a/ansible/roles/nova/tasks/bootstrap.yml
+++ b/ansible/roles/nova/tasks/bootstrap.yml
@@ -59,7 +59,7 @@
     insecure_registry: "{{ docker_insecure_registry }}"
     name: bootstrap_nova
     image: "{{ nova_api_image_full }}"
-    volumes: "{{ node_config_directory }}/nova-api/:/opt/kolla/nova-api/:ro"
+    volumes: "{{ node_config_directory }}/nova-api/:/opt/kolla/config_files/:ro"
     env:
       KOLLA_BOOTSTRAP:
       KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}"
diff --git a/ansible/roles/nova/tasks/config.yml b/ansible/roles/nova/tasks/config.yml
index b1ea0df05..917ef25d2 100644
--- a/ansible/roles/nova/tasks/config.yml
+++ b/ansible/roles/nova/tasks/config.yml
@@ -19,6 +19,11 @@
     config_dest: "{{ node_config_directory }}/{{ service_name }}/nova.conf"
   when: inventory_hostname in groups['nova-api']
 
+- name: Copying Nova API JSON configuration file
+  template:
+    src: "roles/nova/templates/nova-api.json.j2"
+    dest: "{{ node_config_directory }}/nova-api/config.json"
+
 - include: ../../config.yml
   vars:
     service_name: "nova-conductor"
@@ -39,6 +44,11 @@
     config_dest: "{{ node_config_directory }}/{{ service_name }}/nova.conf"
   when: inventory_hostname in groups['nova-conductor']
 
+- name: Copying Nova Conductor JSON configuration file
+  template:
+    src: "roles/nova/templates/nova-conductor.json.j2"
+    dest: "{{ node_config_directory }}/nova-conductor/config.json"
+
 - include: ../../config.yml
   vars:
     service_name: "nova-consoleauth"
@@ -59,6 +69,11 @@
     config_dest: "{{ node_config_directory }}/{{ service_name }}/nova.conf"
   when: inventory_hostname in groups['nova-consoleauth']
 
+- name: Copying Nova Consoleauth JSON configuration file
+  template:
+    src: "roles/nova/templates/nova-consoleauth.json.j2"
+    dest: "{{ node_config_directory }}/nova-consoleauth/config.json"
+
 - include: ../../config.yml
   vars:
     service_name: "nova-scheduler"
@@ -79,6 +94,11 @@
     config_dest: "{{ node_config_directory }}/{{ service_name }}/nova.conf"
   when: inventory_hostname in groups['nova-scheduler']
 
+- name: Copying Nova Scheduler JSON configuration file
+  template:
+    src: "roles/nova/templates/nova-scheduler.json.j2"
+    dest: "{{ node_config_directory }}/nova-scheduler/config.json"
+
 - include: ../../config.yml
   vars:
     service_name: "nova-compute"
@@ -99,6 +119,11 @@
     config_dest: "{{ node_config_directory }}/{{ service_name }}/nova.conf"
   when: inventory_hostname in groups['compute']
 
+- name: Copying Nova Compute JSON configuration file
+  template:
+    src: "roles/nova/templates/nova-compute.json.j2"
+    dest: "{{ node_config_directory }}/nova-compute/config.json"
+
 - include: ../../config.yml
   vars:
     service_name: "nova-novncproxy"
@@ -118,3 +143,13 @@
       - "{{ node_templates_directory }}/{{ service_name }}/{{ service_name }}.conf_augment"
     config_dest: "{{ node_config_directory }}/{{ service_name }}/nova.conf"
   when: inventory_hostname in groups['nova-novncproxy']
+
+- name: Copying Nova Novncproxy JSON configuration file
+  template:
+    src: "roles/nova/templates/nova-novncproxy.json.j2"
+    dest: "{{ node_config_directory }}/nova-novncproxy/config.json"
+
+- name: Copying Nova Libvirt JSON configuration file
+  template:
+    src: "roles/nova/templates/nova-libvirt.json.j2"
+    dest: "{{ node_config_directory }}/nova-libvirt/config.json"
diff --git a/ansible/roles/nova/tasks/start.yml b/ansible/roles/nova/tasks/start.yml
index b6b657c24..09501330b 100644
--- a/ansible/roles/nova/tasks/start.yml
+++ b/ansible/roles/nova/tasks/start.yml
@@ -16,7 +16,7 @@
     name: nova_libvirt
     image: "{{ nova_libvirt_image_full }}"
     volumes:
-      - "{{ node_config_directory }}/nova-libvirt/:/opt/kolla/nova-libvirt/:ro"
+      - "{{ node_config_directory }}/nova-libvirt/:/opt/kolla/config_files/:ro"
       - "/run:/run"
       - "/sys/fs/cgroup:/sys/fs/cgroup"
     volumes_from:
@@ -41,7 +41,7 @@
     name: nova_api
     image: "{{ nova_api_image_full }}"
     volumes:
-      - "{{ node_config_directory }}/nova-api/:/opt/kolla/nova-api/:ro"
+      - "{{ node_config_directory }}/nova-api/:/opt/kolla/config_files/:ro"
       - "/lib/modules:/lib/modules:ro"
     env:
       KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}"
@@ -61,7 +61,7 @@
     insecure_registry: "{{ docker_insecure_registry }}"
     name: nova_conductor
     image: "{{ nova_conductor_image_full }}"
-    volumes: "{{ node_config_directory }}/nova-conductor/:/opt/kolla/nova-conductor/:ro"
+    volumes: "{{ node_config_directory }}/nova-conductor/:/opt/kolla/config_files/:ro"
     env:
       KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}"
   when: inventory_hostname in groups['nova-conductor']
@@ -80,7 +80,7 @@
     insecure_registry: "{{ docker_insecure_registry }}"
     name: nova_consoleauth
     image: "{{ nova_consoleauth_image_full }}"
-    volumes: "{{ node_config_directory }}/nova-consoleauth/:/opt/kolla/nova-consoleauth/:ro"
+    volumes: "{{ node_config_directory }}/nova-consoleauth/:/opt/kolla/config_files/:ro"
     env:
       KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}"
   when: inventory_hostname in groups['nova-consoleauth']
@@ -99,7 +99,7 @@
     insecure_registry: "{{ docker_insecure_registry }}"
     name: nova_novncproxy
     image: "{{ nova_novncproxy_image_full }}"
-    volumes: "{{ node_config_directory }}/nova-novncproxy/:/opt/kolla/nova-novncproxy/:ro"
+    volumes: "{{ node_config_directory }}/nova-novncproxy/:/opt/kolla/config_files/:ro"
     env:
       KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}"
   when: inventory_hostname in groups['nova-novncproxy']
@@ -118,7 +118,7 @@
     insecure_registry: "{{ docker_insecure_registry }}"
     name: nova_scheduler
     image: "{{ nova_scheduler_image_full }}"
-    volumes: "{{ node_config_directory }}/nova-scheduler/:/opt/kolla/nova-scheduler/:ro"
+    volumes: "{{ node_config_directory }}/nova-scheduler/:/opt/kolla/config_files/:ro"
     env:
       KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}"
   when: inventory_hostname in groups['nova-scheduler']
@@ -139,7 +139,7 @@
     name: nova_compute
     image: "{{ nova_compute_image_full }}"
     volumes:
-      - "{{ node_config_directory }}/nova-compute/:/opt/kolla/nova-compute/:ro"
+      - "{{ node_config_directory }}/nova-compute/:/opt/kolla/config_files/:ro"
       - "/lib/modules:/lib/modules:ro"
       - "/run:/run"
     volumes_from:
diff --git a/ansible/roles/nova/templates/nova-api.json.j2 b/ansible/roles/nova/templates/nova-api.json.j2
new file mode 100644
index 000000000..cf4bdf3f6
--- /dev/null
+++ b/ansible/roles/nova/templates/nova-api.json.j2
@@ -0,0 +1,11 @@
+{
+    "command": "/usr/bin/nova-api",
+    "config_files": [
+        {
+            "source": "/opt/kolla/config_files/nova.conf",
+            "dest": "/etc/nova/nova.conf",
+            "owner": "nova",
+            "perm": "0600"
+        }
+    ]
+}
diff --git a/ansible/roles/nova/templates/nova-compute.json.j2 b/ansible/roles/nova/templates/nova-compute.json.j2
new file mode 100644
index 000000000..c9513d157
--- /dev/null
+++ b/ansible/roles/nova/templates/nova-compute.json.j2
@@ -0,0 +1,11 @@
+{
+    "command": "/usr/bin/nova-compute",
+    "config_files": [
+        {
+            "source": "/opt/kolla/config_files/nova.conf",
+            "dest": "/etc/nova/nova.conf",
+            "owner": "nova",
+            "perm": "0600"
+        }
+    ]
+}
diff --git a/ansible/roles/nova/templates/nova-conductor.json.j2 b/ansible/roles/nova/templates/nova-conductor.json.j2
new file mode 100644
index 000000000..41902783c
--- /dev/null
+++ b/ansible/roles/nova/templates/nova-conductor.json.j2
@@ -0,0 +1,11 @@
+{
+    "command": "/usr/bin/nova-conductor",
+    "config_files": [
+        {
+            "source": "/opt/kolla/config_files/nova.conf",
+            "dest": "/etc/nova/nova.conf",
+            "owner": "nova",
+            "perm": "0600"
+        }
+    ]
+}
diff --git a/ansible/roles/nova/templates/nova-consoleauth.json.j2 b/ansible/roles/nova/templates/nova-consoleauth.json.j2
new file mode 100644
index 000000000..0aaad565c
--- /dev/null
+++ b/ansible/roles/nova/templates/nova-consoleauth.json.j2
@@ -0,0 +1,11 @@
+{
+    "command": "/usr/bin/nova-consoleauth",
+    "config_files": [
+        {
+            "source": "/opt/kolla/config_files/nova.conf",
+            "dest": "/etc/nova/nova.conf",
+            "owner": "nova",
+            "perm": "0600"
+        }
+    ]
+}
diff --git a/ansible/roles/nova/templates/nova-libvirt.json.j2 b/ansible/roles/nova/templates/nova-libvirt.json.j2
new file mode 100644
index 000000000..5ec623dd9
--- /dev/null
+++ b/ansible/roles/nova/templates/nova-libvirt.json.j2
@@ -0,0 +1,4 @@
+{
+    "command": "/usr/sbin/libvirtd",
+    "config_files": []
+}
diff --git a/ansible/roles/nova/templates/nova-network.json.j2 b/ansible/roles/nova/templates/nova-network.json.j2
new file mode 100644
index 000000000..eea74c71d
--- /dev/null
+++ b/ansible/roles/nova/templates/nova-network.json.j2
@@ -0,0 +1,11 @@
+{
+    "command": "/usr/bin/nova-network",
+    "config_files": [
+        {
+            "source": "/opt/kolla/config_files/nova.conf",
+            "dest": "/etc/nova/nova.conf",
+            "owner": "nova",
+            "perm": "0600"
+        }
+    ]
+}
diff --git a/ansible/roles/nova/templates/nova-novncproxy.json.j2 b/ansible/roles/nova/templates/nova-novncproxy.json.j2
new file mode 100644
index 000000000..c565202a7
--- /dev/null
+++ b/ansible/roles/nova/templates/nova-novncproxy.json.j2
@@ -0,0 +1,11 @@
+{
+    "command": "/usr/bin/nova-novncproxy",
+    "config_files": [
+        {
+            "source": "/opt/kolla/config_files/nova.conf",
+            "dest": "/etc/nova/nova.conf",
+            "owner": "nova",
+            "perm": "0600"
+        }
+    ]
+}
diff --git a/ansible/roles/nova/templates/nova-scheduler.json.j2 b/ansible/roles/nova/templates/nova-scheduler.json.j2
new file mode 100644
index 000000000..3e34eedd7
--- /dev/null
+++ b/ansible/roles/nova/templates/nova-scheduler.json.j2
@@ -0,0 +1,11 @@
+{
+    "command": "/usr/bin/nova-scheduler",
+    "config_files": [
+        {
+            "source": "/opt/kolla/config_files/nova.conf",
+            "dest": "/etc/nova/nova.conf",
+            "owner": "nova",
+            "perm": "0600"
+        }
+    ]
+}
diff --git a/docker/nova/nova-api/start.sh b/docker/nova/nova-api/start.sh
index ad25ba65c..c61c37feb 100755
--- a/docker/nova/nova-api/start.sh
+++ b/docker/nova/nova-api/start.sh
@@ -1,14 +1,12 @@
 #!/bin/bash
 set -o errexit
 
-CMD="/usr/bin/nova-api"
-ARGS=""
-
 # Loading common functions.
 source /opt/kolla/kolla-common.sh
 
-# Execute config strategy
-set_configs
+# Generate run command
+python /opt/kolla/set_configs.py
+CMD=$(cat /run_command)
 
 # Bootstrap and exit if KOLLA_BOOTSTRAP variable is set. This catches all cases
 # of the KOLLA_BOOTSTRAP variable being set, including empty.
@@ -17,4 +15,5 @@ if [[ "${!KOLLA_BOOTSTRAP[@]}" ]]; then
     exit 0
 fi
 
-exec $CMD $ARGS
+echo "Running command: ${CMD}"
+exec $CMD
diff --git a/docker/nova/nova-compute/start.sh b/docker/nova/nova-compute/start.sh
index 48e77542b..6191ce851 100755
--- a/docker/nova/nova-compute/start.sh
+++ b/docker/nova/nova-compute/start.sh
@@ -1,13 +1,12 @@
 #!/bin/bash
 set -o errexit
 
-CMD="/usr/bin/nova-compute"
-ARGS=""
-
 # Loading common functions.
 source /opt/kolla/kolla-common.sh
 
-# Execute config strategy
-set_configs
+# Generate run command
+python /opt/kolla/set_configs.py
+CMD=$(cat /run_command)
 
-exec $CMD $ARGS
+echo "Running command: ${CMD}"
+exec $CMD
diff --git a/docker/nova/nova-conductor/start.sh b/docker/nova/nova-conductor/start.sh
index 1fe7d0586..6191ce851 100755
--- a/docker/nova/nova-conductor/start.sh
+++ b/docker/nova/nova-conductor/start.sh
@@ -1,13 +1,12 @@
 #!/bin/bash
 set -o errexit
 
-CMD="/usr/bin/nova-conductor"
-ARGS=""
-
 # Loading common functions.
 source /opt/kolla/kolla-common.sh
 
-# Execute config strategy
-set_configs
+# Generate run command
+python /opt/kolla/set_configs.py
+CMD=$(cat /run_command)
 
-exec $CMD $ARGS
+echo "Running command: ${CMD}"
+exec $CMD
diff --git a/docker/nova/nova-consoleauth/start.sh b/docker/nova/nova-consoleauth/start.sh
index 1abccde19..6191ce851 100755
--- a/docker/nova/nova-consoleauth/start.sh
+++ b/docker/nova/nova-consoleauth/start.sh
@@ -1,13 +1,12 @@
 #!/bin/bash
 set -o errexit
 
-CMD="/usr/bin/nova-consoleauth"
-ARGS=""
-
 # Loading common functions.
 source /opt/kolla/kolla-common.sh
 
-# Execute config strategy
-set_configs
+# Generate run command
+python /opt/kolla/set_configs.py
+CMD=$(cat /run_command)
 
-exec $CMD $ARGS
+echo "Running command: ${CMD}"
+exec $CMD
diff --git a/docker/nova/nova-libvirt/start.sh b/docker/nova/nova-libvirt/start.sh
index ae0de867b..aa07f62dd 100755
--- a/docker/nova/nova-libvirt/start.sh
+++ b/docker/nova/nova-libvirt/start.sh
@@ -1,14 +1,12 @@
 #!/bin/bash
 set -o errexit
 
-CMD="/usr/sbin/libvirtd"
-ARGS=""
-
 # Loading common functions.
 source /opt/kolla/kolla-common.sh
 
-# Execute config strategy
-set_configs
+# Generate run command
+python /opt/kolla/set_configs.py
+CMD=$(cat /run_command)
 
 # TODO(SamYaple): Tweak libvirt.conf rather than change permissions.
 # Fix permissions for libvirt
@@ -17,4 +15,5 @@ if [[ -c /dev/kvm ]]; then
     chown root:kvm /dev/kvm
 fi
 
-exec $CMD $ARGS
+echo "Running command: ${CMD}"
+exec $CMD
diff --git a/docker/nova/nova-network/start.sh b/docker/nova/nova-network/start.sh
index 88f941b33..2f8254b89 100755
--- a/docker/nova/nova-network/start.sh
+++ b/docker/nova/nova-network/start.sh
@@ -1,13 +1,11 @@
 #!/bin/bash
 set -o errexit
 
-CMD="/usr/bin/nova-network"
-ARGS=""
-
 # Loading common functions.
 source /opt/kolla/kolla-common.sh
 
-# Execute config strategy
-set_configs
+python /opt/kolla/set_configs.py
+CMD=$(cat /run_command)
 
-exec $CMD $ARGS
+echo "Running command: ${CMD}"
+exec $CMD
diff --git a/docker/nova/nova-novncproxy/start.sh b/docker/nova/nova-novncproxy/start.sh
index 6e59d1253..6191ce851 100755
--- a/docker/nova/nova-novncproxy/start.sh
+++ b/docker/nova/nova-novncproxy/start.sh
@@ -1,13 +1,12 @@
 #!/bin/bash
 set -o errexit
 
-CMD="/usr/bin/nova-novncproxy"
-ARGS=""
-
 # Loading common functions.
 source /opt/kolla/kolla-common.sh
 
-# Execute config strategy
-set_configs
+# Generate run command
+python /opt/kolla/set_configs.py
+CMD=$(cat /run_command)
 
-exec $CMD $ARGS
+echo "Running command: ${CMD}"
+exec $CMD
diff --git a/docker/nova/nova-scheduler/start.sh b/docker/nova/nova-scheduler/start.sh
index d9b3e14eb..6191ce851 100755
--- a/docker/nova/nova-scheduler/start.sh
+++ b/docker/nova/nova-scheduler/start.sh
@@ -1,13 +1,12 @@
 #!/bin/bash
 set -o errexit
 
-CMD="/usr/bin/nova-scheduler"
-ARGS=""
-
 # Loading common functions.
 source /opt/kolla/kolla-common.sh
 
-# Execute config strategy
-set_configs
+# Generate run command
+python /opt/kolla/set_configs.py
+CMD=$(cat /run_command)
 
-exec $CMD $ARGS
+echo "Running command: ${CMD}"
+exec $CMD
-- 
GitLab