BryanDavis has uploaded a new change for review.
https://gerrit.wikimedia.org/r/306696
Change subject: horizon: use service::uwsgi+nginx
......................................................................
horizon: use service::uwsgi+nginx
Replace Apache+mod_wsgi with nginx and service::uwsgi. This will make
mixing horizon and other "modern" python apps on the same host easier.
The service::uwsgi define currently has a comment that 'deployment'
parameter which this is (ab)using to disable scap3 deployment setup will
be removed in a future version. This usage probably demonstrates
a reasonable use-case for not doing so.
Change-Id: I236bf98201188f833387887c159c5548af285ca6
---
M hieradata/role/common/horizon.yaml
M modules/openstack/manifests/horizon/service.pp
A modules/openstack/templates/common/horizon/nginx.conf.erb
D modules/openstack/templates/kilo/horizon/horizon.wikimedia.org.erb
D modules/openstack/templates/kilo/horizon/labtesthorizon.wikimedia.org.erb
D modules/openstack/templates/liberty/horizon/horizon.wikimedia.org.erb
D modules/openstack/templates/liberty/horizon/labtesthorizon.wikimedia.org.erb
D modules/openstack/templates/mitaka/horizon/horizon.wikimedia.org.erb
D modules/openstack/templates/mitaka/horizon/labtesthorizon.wikimedia.org.erb
9 files changed, 68 insertions(+), 196 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/operations/puppet
refs/changes/96/306696/1
diff --git a/hieradata/role/common/horizon.yaml
b/hieradata/role/common/horizon.yaml
index 4860ae1..97bda47 100644
--- a/hieradata/role/common/horizon.yaml
+++ b/hieradata/role/common/horizon.yaml
@@ -4,3 +4,4 @@
value: standard
memcached::ip: 127.0.0.1
+nginx::variant: light
diff --git a/modules/openstack/manifests/horizon/service.pp
b/modules/openstack/manifests/horizon/service.pp
index 6452ac8..c80c12c 100644
--- a/modules/openstack/manifests/horizon/service.pp
+++ b/modules/openstack/manifests/horizon/service.pp
@@ -20,11 +20,7 @@
ensure => present,
}
- include ::apache
- include ::apache::mod::ssl
- include ::apache::mod::wsgi
- include ::apache::mod::rewrite
- include ::apache::mod::headers
+ include ::nginx
include ::memcached
# Blank out these files so that the (broken) dashboard
@@ -84,21 +80,22 @@
mode => '0440',
}
- file {
'/usr/share/openstack-dashboard/openstack_dashboard/static/dashboard/img/logo.png':
+ $app_dir = '${app_dir}'
+ file { "${app_dir}/openstack_dashboard/static/dashboard/img/logo.png":
source =>
'puppet:///modules/openstack/horizon/216px-Wikimedia_labs_dashboard_logo.png',
owner => 'horizon',
group => 'horizon',
require => Package['openstack-dashboard'],
mode => '0444',
}
- file {
'/usr/share/openstack-dashboard/openstack_dashboard/static/dashboard/img/logo-splash.png':
+ file {
"${app_dir}/openstack_dashboard/static/dashboard/img/logo-splash.png":
source =>
'puppet:///modules/openstack/horizon/180px-Wikimedia_labs_dashboard_splash.png',
owner => 'horizon',
group => 'horizon',
require => Package['openstack-dashboard'],
mode => '0444',
}
- file {
'/usr/share/openstack-dashboard/openstack_dashboard/static/dashboard/img/favicon.ico':
+ file { "${app_dir}/openstack_dashboard/static/dashboard/img/favicon.ico":
source => 'puppet:///modules/openstack/horizon/Wikimedia_labs.ico',
owner => 'horizon',
group => 'horizon',
@@ -141,28 +138,28 @@
}
# Install the designate dashboard
- file { '/usr/share/openstack-dashboard/openstack_dashboard/local':
+ file { "${app_dir}/openstack_dashboard/local":
ensure => 'directory',
owner => 'root',
group => 'root',
mode => '0644',
require => Package['python-designate-dashboard',
'openstack-dashboard'],
}
- file { '/usr/share/openstack-dashboard/openstack_dashboard/local/enabled':
+ file { "${app_dir}/openstack_dashboard/local/enabled":
ensure => 'directory',
owner => 'root',
group => 'root',
mode => '0644',
require => Package['python-designate-dashboard',
'openstack-dashboard'],
}
- file {
'/usr/share/openstack-dashboard/openstack_dashboard/local/enabled/_70_dns_add_group.py':
+ file { "${app_dir}/openstack_dashboard/local/enabled/_70_dns_add_group.py":
source =>
"puppet:///modules/openstack/${openstack_version}/designate/dashboard/_70_dns_add_group.py",
owner => 'root',
group => 'root',
mode => '0644',
require => Package['python-designate-dashboard',
'openstack-dashboard'],
}
- file {
'/usr/share/openstack-dashboard/openstack_dashboard/local/enabled/_71_dns_project.py':
+ file { "${app_dir}/openstack_dashboard/local/enabled/_71_dns_project.py":
source =>
"puppet:///modules/openstack/${openstack_version}/designate/dashboard/_71_dns_project.py",
owner => 'root',
group => 'root',
@@ -179,7 +176,7 @@
require => Package['python-designate-dashboard',
'openstack-dashboard'],
recurse => true
}
- file {
'/usr/share/openstack-dashboard/openstack_dashboard/local/enabled/_1922_project_proxy_panel.py':
+ file {
"${app_dir}/openstack_dashboard/local/enabled/_1922_project_proxy_panel.py":
source =>
"puppet:///modules/openstack/${openstack_version}/horizon/proxy_enable.py",
owner => 'root',
group => 'root',
@@ -204,8 +201,23 @@
mode => '0744',
}
- apache::site { $webserver_hostname:
- content =>
template("openstack/${openstack_version}/horizon/${webserver_hostname}.erb"),
- require => File['/etc/openstack-dashboard/local_settings.py'],
+ $uwsgi_port = 8080
+ service::uwsgi { 'horizon':
+ port => $uwsgi_port,
+ config => {
+ chdir => $app_dir,
+ wsgi-file => 'openstack_dashboard/wsgi/django.wsgi',
+ uid => 'horizon',
+ gid => 'horizon',
+ vacuum => true,
+ },
+ healthcheck_url => '/',
+ firejail => false,
+ # We don't use scap3 to deploy, the files are already here
+ deployment => 'puppet',
+ require => File['/etc/openstack-dashboard/local_settings.py'],
+ }
+ nginx::site { 'horizon':
+ content => template('openstack/horizon/nginx.conf.erb'),
}
}
diff --git a/modules/openstack/templates/common/horizon/nginx.conf.erb
b/modules/openstack/templates/common/horizon/nginx.conf.erb
new file mode 100644
index 0000000..11cb7a3
--- /dev/null
+++ b/modules/openstack/templates/common/horizon/nginx.conf.erb
@@ -0,0 +1,39 @@
+# This file is managed by Puppet.
+# See modules/openstack/templates/common/horizon/nginx.conf.erb
+
+server {
+ listen 80;
+ server_name <%= @webserver_hostname %>;
+ charset utf-8;
+ root <%= @app_dir %>;
+
+ if ($http_x_forwared_proto != "https") {
+ add_header Vary X-Forwarded-Proto
+ rewrite ^(.*)$ https://$server_name$1 permanent;
+ }
+
+ location /static/ {
+ sendfile on;
+ sendfile_max_chunk 1m;
+ tcp_nopush on;
+ }
+
+ location / {
+ proxy_redirect off;
+ proxy_buffering off;
+ proxy_http_version 1.1;
+
+ proxy_set_header Connection "";
+ proxy_set_header Proxy-Connection "Keep-Alive";
+
+ # Pass Host header on to backend service
+ proxy_set_header X-Forwarded-Host $host;
+ proxy_set_header Host $host;
+
+ # Pass X-Forwarded-For on to backend service
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+
+ proxy_pass http://127.0.0.1:<%= @uwsgi_port %>;
+ }
+}
+# vim:ft=nginx:sw=2:ts=2:sts=2:et:
diff --git a/modules/openstack/templates/kilo/horizon/horizon.wikimedia.org.erb
b/modules/openstack/templates/kilo/horizon/horizon.wikimedia.org.erb
deleted file mode 100644
index 9041950..0000000
--- a/modules/openstack/templates/kilo/horizon/horizon.wikimedia.org.erb
+++ /dev/null
@@ -1,30 +0,0 @@
-#####################################################################
-### THIS FILE IS MANAGED BY PUPPET
-### puppet:///openstack/horizon.wikimedia.org
-#####################################################################
-# vim: filetype=apache
-
-# This config is behind misc-web which handles ssl for us.
-<VirtualHost *:80>
- ServerName <%= @webserver_hostname %>
-
- RewriteEngine on
- RewriteCond %{HTTP:X-Forwarded-Proto} !https
- RewriteCond %{REQUEST_URI} !^/status$
- RewriteRule ^/(.*)$ https://%{HTTP_HOST}%{REQUEST_URI}
[R=301,E=ProtoRedirect]
- Header always merge Vary X-Forwarded-Proto env=ProtoRedirect
-
- WSGIScriptAlias /
/usr/share/openstack-dashboard/openstack_dashboard/wsgi/django.wsgi
- WSGIDaemonProcess horizon user=horizon group=horizon processes=3 threads=10
- WSGIProcessGroup horizon
- Alias /static /usr/share/openstack-dashboard/openstack_dashboard/static/
- <Directory /usr/share/openstack-dashboard/openstack_dashboard/wsgi>
- <IfVersion >= 2.4>
- Require all granted
- </IfVersion>
- <IfVersion < 2.4>
- Order allow,deny
- Allow from all
- </IfVersion>
- </Directory>
-</VirtualHost>
diff --git
a/modules/openstack/templates/kilo/horizon/labtesthorizon.wikimedia.org.erb
b/modules/openstack/templates/kilo/horizon/labtesthorizon.wikimedia.org.erb
deleted file mode 100644
index 9041950..0000000
--- a/modules/openstack/templates/kilo/horizon/labtesthorizon.wikimedia.org.erb
+++ /dev/null
@@ -1,30 +0,0 @@
-#####################################################################
-### THIS FILE IS MANAGED BY PUPPET
-### puppet:///openstack/horizon.wikimedia.org
-#####################################################################
-# vim: filetype=apache
-
-# This config is behind misc-web which handles ssl for us.
-<VirtualHost *:80>
- ServerName <%= @webserver_hostname %>
-
- RewriteEngine on
- RewriteCond %{HTTP:X-Forwarded-Proto} !https
- RewriteCond %{REQUEST_URI} !^/status$
- RewriteRule ^/(.*)$ https://%{HTTP_HOST}%{REQUEST_URI}
[R=301,E=ProtoRedirect]
- Header always merge Vary X-Forwarded-Proto env=ProtoRedirect
-
- WSGIScriptAlias /
/usr/share/openstack-dashboard/openstack_dashboard/wsgi/django.wsgi
- WSGIDaemonProcess horizon user=horizon group=horizon processes=3 threads=10
- WSGIProcessGroup horizon
- Alias /static /usr/share/openstack-dashboard/openstack_dashboard/static/
- <Directory /usr/share/openstack-dashboard/openstack_dashboard/wsgi>
- <IfVersion >= 2.4>
- Require all granted
- </IfVersion>
- <IfVersion < 2.4>
- Order allow,deny
- Allow from all
- </IfVersion>
- </Directory>
-</VirtualHost>
diff --git
a/modules/openstack/templates/liberty/horizon/horizon.wikimedia.org.erb
b/modules/openstack/templates/liberty/horizon/horizon.wikimedia.org.erb
deleted file mode 100644
index 9041950..0000000
--- a/modules/openstack/templates/liberty/horizon/horizon.wikimedia.org.erb
+++ /dev/null
@@ -1,30 +0,0 @@
-#####################################################################
-### THIS FILE IS MANAGED BY PUPPET
-### puppet:///openstack/horizon.wikimedia.org
-#####################################################################
-# vim: filetype=apache
-
-# This config is behind misc-web which handles ssl for us.
-<VirtualHost *:80>
- ServerName <%= @webserver_hostname %>
-
- RewriteEngine on
- RewriteCond %{HTTP:X-Forwarded-Proto} !https
- RewriteCond %{REQUEST_URI} !^/status$
- RewriteRule ^/(.*)$ https://%{HTTP_HOST}%{REQUEST_URI}
[R=301,E=ProtoRedirect]
- Header always merge Vary X-Forwarded-Proto env=ProtoRedirect
-
- WSGIScriptAlias /
/usr/share/openstack-dashboard/openstack_dashboard/wsgi/django.wsgi
- WSGIDaemonProcess horizon user=horizon group=horizon processes=3 threads=10
- WSGIProcessGroup horizon
- Alias /static /usr/share/openstack-dashboard/openstack_dashboard/static/
- <Directory /usr/share/openstack-dashboard/openstack_dashboard/wsgi>
- <IfVersion >= 2.4>
- Require all granted
- </IfVersion>
- <IfVersion < 2.4>
- Order allow,deny
- Allow from all
- </IfVersion>
- </Directory>
-</VirtualHost>
diff --git
a/modules/openstack/templates/liberty/horizon/labtesthorizon.wikimedia.org.erb
b/modules/openstack/templates/liberty/horizon/labtesthorizon.wikimedia.org.erb
deleted file mode 100644
index 9041950..0000000
---
a/modules/openstack/templates/liberty/horizon/labtesthorizon.wikimedia.org.erb
+++ /dev/null
@@ -1,30 +0,0 @@
-#####################################################################
-### THIS FILE IS MANAGED BY PUPPET
-### puppet:///openstack/horizon.wikimedia.org
-#####################################################################
-# vim: filetype=apache
-
-# This config is behind misc-web which handles ssl for us.
-<VirtualHost *:80>
- ServerName <%= @webserver_hostname %>
-
- RewriteEngine on
- RewriteCond %{HTTP:X-Forwarded-Proto} !https
- RewriteCond %{REQUEST_URI} !^/status$
- RewriteRule ^/(.*)$ https://%{HTTP_HOST}%{REQUEST_URI}
[R=301,E=ProtoRedirect]
- Header always merge Vary X-Forwarded-Proto env=ProtoRedirect
-
- WSGIScriptAlias /
/usr/share/openstack-dashboard/openstack_dashboard/wsgi/django.wsgi
- WSGIDaemonProcess horizon user=horizon group=horizon processes=3 threads=10
- WSGIProcessGroup horizon
- Alias /static /usr/share/openstack-dashboard/openstack_dashboard/static/
- <Directory /usr/share/openstack-dashboard/openstack_dashboard/wsgi>
- <IfVersion >= 2.4>
- Require all granted
- </IfVersion>
- <IfVersion < 2.4>
- Order allow,deny
- Allow from all
- </IfVersion>
- </Directory>
-</VirtualHost>
diff --git
a/modules/openstack/templates/mitaka/horizon/horizon.wikimedia.org.erb
b/modules/openstack/templates/mitaka/horizon/horizon.wikimedia.org.erb
deleted file mode 100644
index 9041950..0000000
--- a/modules/openstack/templates/mitaka/horizon/horizon.wikimedia.org.erb
+++ /dev/null
@@ -1,30 +0,0 @@
-#####################################################################
-### THIS FILE IS MANAGED BY PUPPET
-### puppet:///openstack/horizon.wikimedia.org
-#####################################################################
-# vim: filetype=apache
-
-# This config is behind misc-web which handles ssl for us.
-<VirtualHost *:80>
- ServerName <%= @webserver_hostname %>
-
- RewriteEngine on
- RewriteCond %{HTTP:X-Forwarded-Proto} !https
- RewriteCond %{REQUEST_URI} !^/status$
- RewriteRule ^/(.*)$ https://%{HTTP_HOST}%{REQUEST_URI}
[R=301,E=ProtoRedirect]
- Header always merge Vary X-Forwarded-Proto env=ProtoRedirect
-
- WSGIScriptAlias /
/usr/share/openstack-dashboard/openstack_dashboard/wsgi/django.wsgi
- WSGIDaemonProcess horizon user=horizon group=horizon processes=3 threads=10
- WSGIProcessGroup horizon
- Alias /static /usr/share/openstack-dashboard/openstack_dashboard/static/
- <Directory /usr/share/openstack-dashboard/openstack_dashboard/wsgi>
- <IfVersion >= 2.4>
- Require all granted
- </IfVersion>
- <IfVersion < 2.4>
- Order allow,deny
- Allow from all
- </IfVersion>
- </Directory>
-</VirtualHost>
diff --git
a/modules/openstack/templates/mitaka/horizon/labtesthorizon.wikimedia.org.erb
b/modules/openstack/templates/mitaka/horizon/labtesthorizon.wikimedia.org.erb
deleted file mode 100644
index 9041950..0000000
---
a/modules/openstack/templates/mitaka/horizon/labtesthorizon.wikimedia.org.erb
+++ /dev/null
@@ -1,30 +0,0 @@
-#####################################################################
-### THIS FILE IS MANAGED BY PUPPET
-### puppet:///openstack/horizon.wikimedia.org
-#####################################################################
-# vim: filetype=apache
-
-# This config is behind misc-web which handles ssl for us.
-<VirtualHost *:80>
- ServerName <%= @webserver_hostname %>
-
- RewriteEngine on
- RewriteCond %{HTTP:X-Forwarded-Proto} !https
- RewriteCond %{REQUEST_URI} !^/status$
- RewriteRule ^/(.*)$ https://%{HTTP_HOST}%{REQUEST_URI}
[R=301,E=ProtoRedirect]
- Header always merge Vary X-Forwarded-Proto env=ProtoRedirect
-
- WSGIScriptAlias /
/usr/share/openstack-dashboard/openstack_dashboard/wsgi/django.wsgi
- WSGIDaemonProcess horizon user=horizon group=horizon processes=3 threads=10
- WSGIProcessGroup horizon
- Alias /static /usr/share/openstack-dashboard/openstack_dashboard/static/
- <Directory /usr/share/openstack-dashboard/openstack_dashboard/wsgi>
- <IfVersion >= 2.4>
- Require all granted
- </IfVersion>
- <IfVersion < 2.4>
- Order allow,deny
- Allow from all
- </IfVersion>
- </Directory>
-</VirtualHost>
--
To view, visit https://gerrit.wikimedia.org/r/306696
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I236bf98201188f833387887c159c5548af285ca6
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: BryanDavis <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits