Add python WSGI server

This commit adds and configures mod_wsgi
for apps.openstack.org.

Change-Id: I860ba015aff8e555a69c361b414e3214e9a2107f
Depends-On: I2fa9686d3e5db4ee43a02aa7d09b998472e02bf6
This commit is contained in:
Christopher Aedo 2015-11-13 12:02:48 -08:00
parent c2814473c9
commit 8fd856b594
3 changed files with 56 additions and 46 deletions

View File

@ -13,6 +13,7 @@ class apps_site (
$ssl_chain_file = '/etc/ssl/certs/ca-certificates.crt',
) {
include ::httpd::ssl
include ::httpd::mod::wsgi
if !defined(Package['git']) {
package { 'git':
@ -98,6 +99,37 @@ class apps_site (
}
}
file { "${root_dir}/openstack_catalog/local_settings.py":
ensure => present,
mode => '0644',
content => template('apps_site/local_settings.erb'),
require => Vcsrepo[$root_dir],
}
exec { 'install-app_catalog' :
command => "/usr/local/bin/pip install ${root_dir}",
cwd => $root_dir,
refreshonly => true,
subscribe => Vcsrepo[$root_dir],
require => File["${root_dir}/openstack_catalog/local_settings.py"],
notify => Service['httpd'],
}
file { "${root_dir}/openstack_catalog/web/static/CACHE":
ensure => directory,
owner => 'www-data',
group => 'www-data',
mode => '0755',
require => Vcsrepo[$root_dir],
}
exec { 'collect-static' :
command => "/usr/bin/python ${root_dir}/manage.py collectstatic --noinput",
refreshonly => true,
subscribe => Vcsrepo[$root_dir],
require => File["${root_dir}/openstack_catalog/web/static/CACHE"],
}
exec { 'make_assets_json' :
command => "${root_dir}/tools/update_assets.sh",
path => '/usr/local/bin:/usr/bin:/bin',

View File

@ -0,0 +1,3 @@
ASSETS_FILE = '<%= @root_dir %>/openstack_catalog/web/api/v1/assets'
STATIC_ROOT = '<%= @root_dir %>/openstack_catalog/web/static'
COMPRESS_ENABLED = True

View File

@ -2,6 +2,12 @@
ServerAdmin <%= @serveradmin %>
ServerName <%= @vhost_name %>
WSGIProcessGroup appcatalog
WSGIDaemonProcess appcatalog user=www-data group=www-data threads=5 python-path=/usr/lib/python2.7:/usr/lib/python2.7/plat-x86_64-linux-gnu:/usr/lib/python2.7/lib-tk:/usr/lib/python2.7/lib-old:/usr/lib/python2.7/lib-dynload:/usr/local/lib/python2.7/dist-packages:/usr/lib/python2.7/dist-packages
WSGIScriptAlias / /usr/local/lib/python2.7/dist-packages/openstack_catalog/wsgi.py
Alias /static/ <%= @root_dir %>/openstack_catalog/web/static/
DocumentRoot <%= @docroot %>
<Directory />
Options FollowSymLinks
@ -11,28 +17,11 @@
Allow from all
Satisfy Any
</Directory>
<Location "/api/v1/assets">
Header set Access-Control-Allow-Origin "*"
Header set Content-type "application/json"
Header set Access-Control-Allow-Headers "Origin, Accept-Encoding, Content-Type, X-App-Catalog-Versions"
Header set Access-Control-Max-Age 3600
Header set Cache-Control max-age=3600
Header set Access-Control-Allow-Methods "GET, OPTIONS"
SetOutputFilter DEFLATE
</Location>
RewriteEngine On
RewriteRule "^/api/v1/assets\.gz$" "-" [T=application/json,E=no-gzip:1]
RewriteCond %{REQUEST_METHOD} OPTIONS
RewriteRule ^(/api/v1/assets)$ /static/blank.json [QSA,L]
RewriteCond "%{HTTP:Accept-Encoding}" "gzip"
RewriteCond "%{REQUEST_FILENAME}\.gz" -s
RewriteRule "^(/api/v1/assets)" "$1\.gz" [QSA]
RedirectMatch ^/api/v1/murano_repo/liberty/(.*)$ http://storage.apps.openstack.org/$1
<Directory /usr/local/lib/python2.7/dist-packages/openstack_catalog/>
Order allow,deny
Allow from all
Satisfy Any
</Directory>
ErrorLog /var/log/apache2/app_site-error.log
@ -48,8 +37,11 @@
ServerAdmin <%= @serveradmin %>
ServerName <%= @vhost_name %>
ErrorLog ${APACHE_LOG_DIR}/<%= @vhost_name %>-ssl-error.log
CustomLog ${APACHE_LOG_DIR}/<%= @vhost_name %>-ssl-access.log combined
WSGIProcessGroup appcatalogssl
WSGIDaemonProcess appcatalogssl user=www-data group=www-data threads=5 python-path=/usr/lib/python2.7:/usr/lib/python2.7/plat-x86_64-linux-gnu:/usr/lib/python2.7/lib-tk:/usr/lib/python2.7/lib-old:/usr/lib/python2.7/lib-dynload:/usr/local/lib/python2.7/dist-packages:/usr/lib/python2.7/dist-packages
WSGIScriptAlias / /usr/local/lib/python2.7/dist-packages/openstack_catalog/wsgi.py
Alias /static/ <%= @root_dir %>/openstack_catalog/web/static/
SSLEngine on
SSLProtocol All -SSLv2 -SSLv3
@ -75,28 +67,11 @@
Allow from all
Satisfy Any
</Directory>
<Location "/api/v1/assets">
Header set Access-Control-Allow-Origin "*"
Header set Content-type "application/json"
Header set Access-Control-Allow-Headers "Origin, Accept-Encoding, Content-Type, X-App-Catalog-Versions"
Header set Access-Control-Max-Age 3600
Header set Cache-Control max-age=3600
Header set Access-Control-Allow-Methods "GET, OPTIONS"
SetOutputFilter DEFLATE
</Location>
RewriteEngine On
RewriteRule "^/api/v1/assets\.gz$" "-" [T=application/json,E=no-gzip:1]
RewriteCond %{REQUEST_METHOD} OPTIONS
RewriteRule ^(/api/v1/assets)$ /static/blank.json [QSA,L]
RewriteCond "%{HTTP:Accept-Encoding}" "gzip"
RewriteCond "%{REQUEST_FILENAME}\.gz" -s
RewriteRule "^(/api/v1/assets)" "$1\.gz" [QSA]
RedirectMatch ^/api/v1/murano_repo/liberty/(.*)$ http://storage.apps.openstack.org/$1
<Directory /usr/local/lib/python2.7/dist-packages/openstack_catalog/>
Order allow,deny
Allow from all
Satisfy Any
</Directory>
ErrorLog /var/log/apache2/app_site-error.log