From e1179eaaf850f3d2dd04a0bcc0ba307d2e9a5603 Mon Sep 17 00:00:00 2001
From: Pete Birley <pete@port.direct>
Date: Tue, 21 Aug 2018 23:40:39 -0500
Subject: [PATCH] Nova: move all config to be driven via chart values

This PS moves nova inline with other charts, and drives all config
directly from the charts values.yaml.

Change-Id: Ia3da97cd32e70e3a5ffe0ed3f3cacfbadfc8cfd6
Signed-off-by: Pete Birley <pete@port.direct>
---
 nova/templates/configmap-etc.yaml             |  7 ++-
 nova/templates/etc/_ssh-config.tpl            |  4 --
 .../etc/_wsgi-nova-placement.conf.tpl         | 50 -------------------
 nova/values.yaml                              | 46 ++++++++++++++---
 4 files changed, 43 insertions(+), 64 deletions(-)
 delete mode 100644 nova/templates/etc/_ssh-config.tpl
 delete mode 100644 nova/templates/etc/_wsgi-nova-placement.conf.tpl

diff --git a/nova/templates/configmap-etc.yaml b/nova/templates/configmap-etc.yaml
index 41cc854d95..cbd69eeae4 100644
--- a/nova/templates/configmap-etc.yaml
+++ b/nova/templates/configmap-etc.yaml
@@ -239,10 +239,9 @@ data:
 {{ include "helm-toolkit.utils.to_oslo_conf" .Values.conf.logging | indent 4 }}
   nova-ironic.conf: |
 {{ include "helm-toolkit.utils.to_oslo_conf" .Values.conf.nova_ironic | indent 4 }}
-  wsgi-nova-placement.conf: |
-{{- tuple .Values.conf.wsgi_placement "etc/_wsgi-nova-placement.conf.tpl" . | include "helm-toolkit.utils.configmap_templater" }}
-  ssh-config.sh: |
-{{- tuple .Values.conf.ssh "etc/_ssh-config.tpl" . | include "helm-toolkit.utils.configmap_templater" }}
+{{- include "helm-toolkit.snippets.values_template_renderer" (dict "envAll" $envAll "template" .Values.conf.wsgi_placement "key" "wsgi-nova-placement.conf" ) | indent 2 }}
+# FIXME(portdirect): why is this file suffixed .sh?
+{{- include "helm-toolkit.snippets.values_template_renderer" (dict "envAll" $envAll "template" .Values.conf.ssh "key" "ssh-config.sh" ) | indent 2 }}
 {{- end }}
 {{- end }}
 {{- if .Values.manifests.configmap_etc }}
diff --git a/nova/templates/etc/_ssh-config.tpl b/nova/templates/etc/_ssh-config.tpl
deleted file mode 100644
index ca2966bf3a..0000000000
--- a/nova/templates/etc/_ssh-config.tpl
+++ /dev/null
@@ -1,4 +0,0 @@
-Host *
-  StrictHostKeyChecking no
-  UserKnownHostsFile /dev/null
-  Port {{ .Values.network.ssh.port }}
diff --git a/nova/templates/etc/_wsgi-nova-placement.conf.tpl b/nova/templates/etc/_wsgi-nova-placement.conf.tpl
deleted file mode 100644
index 43e1e6c80e..0000000000
--- a/nova/templates/etc/_wsgi-nova-placement.conf.tpl
+++ /dev/null
@@ -1,50 +0,0 @@
-{{/*
-Copyright 2017 The Openstack-Helm Authors.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-   http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/}}
-
-Listen 0.0.0.0:{{ tuple "placement" "internal" "api" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
-
-LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
-LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" proxy
-
-SetEnvIf X-Forwarded-For "^.*\..*\..*\..*" forwarded
-CustomLog /dev/stdout combined env=!forwarded
-CustomLog /dev/stdout proxy env=forwarded
-
-<VirtualHost *:{{ tuple "placement" "internal" "api" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }}>
-    WSGIDaemonProcess placement-api processes=1 threads=4 user=nova group=nova display-name=%{GROUP}
-    WSGIProcessGroup placement-api
-    WSGIScriptAlias / /var/www/cgi-bin/nova/nova-placement-api
-    WSGIApplicationGroup %{GLOBAL}
-    WSGIPassAuthorization On
-    <IfVersion >= 2.4>
-      ErrorLogFormat "%{cu}t %M"
-    </IfVersion>
-    ErrorLog /dev/stdout
-
-    SetEnvIf X-Forwarded-For "^.*\..*\..*\..*" forwarded
-    CustomLog /dev/stdout combined env=!forwarded
-    CustomLog /dev/stdout proxy env=forwarded
-</VirtualHost>
-
-Alias /placement /var/www/cgi-bin/nova/nova-placement-api
-<Location /placement>
-    SetHandler wsgi-script
-    Options +ExecCGI
-
-    WSGIProcessGroup placement-api
-    WSGIApplicationGroup %{GLOBAL}
-    WSGIPassAuthorization On
-</Location>
diff --git a/nova/values.yaml b/nova/values.yaml
index ecf2708775..cfb5fc875b 100644
--- a/nova/values.yaml
+++ b/nova/values.yaml
@@ -451,9 +451,11 @@ conf:
       user: "cinder"
       keyring: null
       secret_uuid: 457eb676-33da-42ec-9a8c-9293d545c337
-  ssh:
-    override:
-    append:
+  ssh: |
+    Host *
+      StrictHostKeyChecking no
+      UserKnownHostsFile /dev/null
+      Port {{ .Values.network.ssh.port }}
   rally_tests:
     run_tempest: false
     tests:
@@ -1050,9 +1052,41 @@ conf:
     # INFO means log all usage
     # ERROR means only log unsuccessful attempts
     syslog_log_level=ERROR
-  wsgi_placement:
-    override:
-    append:
+  wsgi_placement: |
+    Listen 0.0.0.0:{{ tuple "placement" "internal" "api" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }}
+
+    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
+    LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" proxy
+
+    SetEnvIf X-Forwarded-For "^.*\..*\..*\..*" forwarded
+    CustomLog /dev/stdout combined env=!forwarded
+    CustomLog /dev/stdout proxy env=forwarded
+
+    <VirtualHost *:{{ tuple "placement" "internal" "api" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }}>
+        WSGIDaemonProcess placement-api processes=1 threads=4 user=nova group=nova display-name=%{GROUP}
+        WSGIProcessGroup placement-api
+        WSGIScriptAlias / /var/www/cgi-bin/nova/nova-placement-api
+        WSGIApplicationGroup %{GLOBAL}
+        WSGIPassAuthorization On
+        <IfVersion >= 2.4>
+          ErrorLogFormat "%{cu}t %M"
+        </IfVersion>
+        ErrorLog /dev/stdout
+
+        SetEnvIf X-Forwarded-For "^.*\..*\..*\..*" forwarded
+        CustomLog /dev/stdout combined env=!forwarded
+        CustomLog /dev/stdout proxy env=forwarded
+    </VirtualHost>
+
+    Alias /placement /var/www/cgi-bin/nova/nova-placement-api
+    <Location /placement>
+        SetHandler wsgi-script
+        Options +ExecCGI
+
+        WSGIProcessGroup placement-api
+        WSGIApplicationGroup %{GLOBAL}
+        WSGIPassAuthorization On
+    </Location>
   rootwrap_filters:
     api_metadata:
       pods: