Deprecate informula wsgi script
All openstack services uses 99% persent same wsgi apache config.
This patch adds functionality to configure barbican apache wsgi config
from the pillar. To do this on cluster level the following file
should be included:
- system.apache.server.site.barbican
The intree wsgi template will be removed when we switch all model
and cookiecutter to use apache template.
Change-Id: Ic0170c14027446c2bf15578f65744bd5ddc07adc
diff --git a/.kitchen.yml b/.kitchen.yml
index 3ecefb3..5116a10 100644
--- a/.kitchen.yml
+++ b/.kitchen.yml
@@ -14,9 +14,14 @@
formula: barbican
grains:
noservices: True
+ dependencies:
+ - name: apache
+ repo: git
+ source: https://github.com/salt-formulas/salt-formula-apache
state_top:
base:
"*":
+ - apache
- barbican
pillars:
top.sls:
diff --git a/barbican/server.sls b/barbican/server.sls
index ce05b71..9cea2e6 100644
--- a/barbican/server.sls
+++ b/barbican/server.sls
@@ -2,6 +2,7 @@
{%- if server.enabled %}
include:
+ - apache
- barbican._ssl
barbican_server_packages:
@@ -25,23 +26,58 @@
- file: /etc/barbican/barbican.conf
- pkg: barbican_server_packages
-/etc/apache2/conf-enabled/barbican-api.conf:
+
+{#- Creation of sites using templates is deprecated, sites should be generated by apache pillar, and enabled by barbican formula #}
+{%- if pillar.get('apache', {}).get('server', {}).get('site', {}).barbican is not defined %}
+
+barbican_cleanup_configs:
file.absent:
+ - name: /etc/apache2/conf-enabled/barbican-api.conf
- require:
- pkg: barbican_server_packages
-
-/etc/apache2/sites-available/barbican-api.conf:
+barbican_apache_conf_file:
file.managed:
+ - name: /etc/apache2/sites-available/barbican-api.conf
- source: salt://barbican/files/{{ server.version }}/barbican-api.apache2.conf.Debian
- template: jinja
- require:
- pkg: barbican_server_packages
+ - barbican_cleanup_configs
-barbican_api_config:
- file.symlink:
- - name: /etc/apache2/sites-enabled/barbican-api.conf
- - target: /etc/apache2/sites-available/barbican-api.conf
+apache_enable_barbican_wsgi:
+ apache_site.enabled:
+ - name: barbican-api
+ - require:
+ - barbican_apache_conf_file
+
+{%- else %}
+
+barbican_cleanup_configs:
+ file.absent:
+ - names:
+ - '/etc/apache2/sites-available/barbican-api.conf'
+ - '/etc/apache2/sites-enabled/barbican-api.conf'
+ - '/etc/apache2/conf-enabled/barbican-api.conf'
+
+barbican_apache_conf_file:
+ file.exists:
+ - names:
+ - /etc/apache2/sites-available/wsgi_barbican.conf
+ - /etc/apache2/sites-available/wsgi_barbican_admin.conf
+ - require:
+ - pkg: barbican_server_packages
+ - barbican_cleanup_configs
+
+apache_enable_barbican_wsgi:
+ apache_site.enabled:
+ - names:
+ - wsgi_barbican
+ - wsgi_barbican_admin
+ - require:
+ - barbican_apache_conf_file
+
+{%- endif %}
barbican_apache_restart:
service.running:
@@ -52,7 +88,7 @@
{%- endif %}
- watch:
- file: /etc/barbican/barbican.conf
- - file: /etc/apache2/sites-available/barbican-api.conf
+ - barbican_apache_conf_file
barbican_server_services:
service.running:
diff --git a/metadata.yml b/metadata.yml
index 7c8d474..09a5a83 100644
--- a/metadata.yml
+++ b/metadata.yml
@@ -1,3 +1,6 @@
name: "barbican"
version: "2017.6"
source: "https://github.com/salt-formulas/salt-formula-barbican"
+dependencies:
+ - name: apache
+ source: "https://github.com/salt-formulas/salt-formula-apache"
diff --git a/tests/pillar/control_cluster.sls b/tests/pillar/control_cluster.sls
index b5fc183..938a5bd 100644
--- a/tests/pillar/control_cluster.sls
+++ b/tests/pillar/control_cluster.sls
@@ -88,4 +88,15 @@
apache:
server:
enabled: true
- default_mpm: event
\ No newline at end of file
+ default_mpm: event
+ mpm:
+ prefork:
+ enabled: true
+ servers:
+ start: 5
+ spare:
+ min: 2
+ max: 10
+ max_requests: 0
+ max_clients: 20
+ limit: 20
diff --git a/tests/pillar/control_single.sls b/tests/pillar/control_single.sls
index 0a94c8e..330f409 100644
--- a/tests/pillar/control_single.sls
+++ b/tests/pillar/control_single.sls
@@ -85,3 +85,57 @@
port: 11211
- host: 10.10.10.12
port: 11211
+apache:
+ server:
+ enabled: true
+ default_mpm: event
+ mpm:
+ prefork:
+ enabled: true
+ servers:
+ start: 5
+ spare:
+ min: 2
+ max: 10
+ max_requests: 0
+ max_clients: 20
+ limit: 20
+ site:
+ barbican:
+ enabled: false
+ available: true
+ type: wsgi
+ name: barbican
+ wsgi:
+ daemon_process: barbican-api
+ processes: 3
+ threads: 10
+ user: barbican
+ group: barbican
+ display_name: '%{GROUP}'
+ script_alias: '/ /usr/bin/barbican-wsgi-api'
+ application_group: '%{GLOBAL}'
+ authorization: 'On'
+ host:
+ address: 127.0.0.1
+ name: 127.0.0.1
+ port: 9311
+ barbican_admin:
+ enabled: false
+ available: true
+ type: wsgi
+ name: barbican_admin
+ wsgi:
+ daemon_process: barbican-api-admin
+ processes: 3
+ threads: 10
+ user: barbican
+ group: barbican
+ display_name: '%{GROUP}'
+ script_alias: '/ /usr/bin/barbican-wsgi-api'
+ application_group: '%{GLOBAL}'
+ authorization: 'On'
+ host:
+ address: 127.0.0.1
+ name: 127.0.0.1
+ port: 9312
diff --git a/tests/pillar/ssl.sls b/tests/pillar/ssl.sls
index 4a067f5..f3799df 100644
--- a/tests/pillar/ssl.sls
+++ b/tests/pillar/ssl.sls
@@ -127,3 +127,57 @@
port: 11211
- host: 10.10.10.12
port: 11211
+apache:
+ server:
+ enabled: true
+ default_mpm: event
+ mpm:
+ prefork:
+ enabled: true
+ servers:
+ start: 5
+ spare:
+ min: 2
+ max: 10
+ max_requests: 0
+ max_clients: 20
+ limit: 20
+ site:
+ barbican:
+ enabled: false
+ available: true
+ type: wsgi
+ name: barbican
+ wsgi:
+ daemon_process: barbican-api
+ processes: 3
+ threads: 10
+ user: barbican
+ group: barbican
+ display_name: '%{GROUP}'
+ script_alias: '/ /usr/bin/barbican-wsgi-api'
+ application_group: '%{GLOBAL}'
+ authorization: 'On'
+ host:
+ address: 127.0.0.1
+ name: 127.0.0.1
+ port: 9311
+ barbican_admin:
+ enabled: false
+ available: true
+ type: wsgi
+ name: barbican_admin
+ wsgi:
+ daemon_process: barbican-api-admin
+ processes: 3
+ threads: 10
+ user: barbican
+ group: barbican
+ display_name: '%{GROUP}'
+ script_alias: '/ /usr/bin/barbican-wsgi-api'
+ application_group: '%{GLOBAL}'
+ authorization: 'On'
+ host:
+ address: 127.0.0.1
+ name: 127.0.0.1
+ port: 9312