From bdbea96326828f2655f6a9a4f580e01ef9db7c1a Mon Sep 17 00:00:00 2001 From: Zhipeng Liu Date: Wed, 22 Apr 2020 00:41:02 +0800 Subject: [PATCH] Allow more generic overrides for placement With this patch we allow for a more easy way of overriding some of the values that may be used in other distros while maintainting the default values if those values are not overriden. The following values are introduced to be overriden: conf: security: software: apache2: binary: start_flags: a2enmod: a2dismod: On which: * binary: the binary to use for launching apache * start_flags: any flags that will be passed to the apache binary call * a2enmod: mods to enable * a2dismod: mods to disable Notice that if there is no overrides given, it should not affect anything and the templates will not be changed as the default values are set to what they used to be as to not disrupt existing deployments. Change-Id: I77940ff847fc5785178ee5cf84cb77bed9f1ec71 Signed-off-by: Zhipeng Liu --- placement/templates/bin/_placement-api.sh.tpl | 21 +++++++++++++++---- placement/values.yaml | 12 +++++++++++ 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/placement/templates/bin/_placement-api.sh.tpl b/placement/templates/bin/_placement-api.sh.tpl index 5cd89188d5..7c5acb35d1 100644 --- a/placement/templates/bin/_placement-api.sh.tpl +++ b/placement/templates/bin/_placement-api.sh.tpl @@ -24,19 +24,32 @@ function start () { cp -a $(type -p placement-api) /var/www/cgi-bin/placement/ if [ -f /etc/apache2/envvars ]; then - # Loading Apache2 ENV variables - source /etc/apache2/envvars + # Loading Apache2 ENV variables + source /etc/apache2/envvars + # The directory below has to be created due to the fact that + # libapache2-mod-wsgi-py3 doesn't create it in contrary by libapache2-mod-wsgi + mkdir -p ${APACHE_RUN_DIR} fi # Get rid of stale pid file if present. rm -f /var/run/apache2/*.pid # Start Apache2 - exec apache2ctl -DFOREGROUND + {{- if .Values.conf.software.apache2.a2enmod }} + {{- range .Values.conf.software.apache2.a2enmod }} + a2enmod {{ . }} + {{- end }} + {{- end }} + {{- if .Values.conf.software.apache2.a2dismod }} + {{- range .Values.conf.software.apache2.a2dismod }} + a2dismod {{ . }} + {{- end }} + {{- end }} + exec {{ .Values.conf.software.apache2.binary }} {{ .Values.conf.software.apache2.start_parameters }} } function stop () { - apache2ctl -k graceful-stop + {{ .Values.conf.software.apache2.binary }} -k graceful-stop } $COMMAND diff --git a/placement/values.yaml b/placement/values.yaml index 1080ab6578..91f589bbbc 100644 --- a/placement/values.yaml +++ b/placement/values.yaml @@ -65,6 +65,18 @@ conf: segregation: 'rule:context_is_admin' admin_or_owner: 'rule:context_is_admin or project_id:%(project_id)s' default: 'rule:admin_or_owner' + software: + apache2: + binary: apache2 + start_parameters: -DFOREGROUND + # Enable/Disable modules + # a2enmod: + # - headers + # - rewrite + # a2dismod: + # - status + a2enmod: null + a2dismod: null placement: DEFAULT: debug: false