Browse Source

Deploy as a wsgi app

Also, correct vcsrepo so it is continuously deployed.

Change-Id: Ibd06de25f0d277d7c8ccb652b50d6a44743934cd
changes/53/224353/2
James E. Blair 7 years ago
parent
commit
fd60552663
  1. 11
      files/django.wsgi
  2. 30
      manifests/init.pp
  3. 28
      templates/odsreg.vhost.erb

11
files/django.wsgi

@ -0,0 +1,11 @@
import os
import sys
path = '/usr/local/odsreg'
if path not in sys.path:
sys.path.append(path)
os.environ['DJANGO_SETTINGS_MODULE'] = 'odsreg.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

30
manifests/init.pp

@ -12,6 +12,7 @@ class odsreg(
) {
include ::httpd
include ::httpd::mod::wsgi
include ::pip
package { 'django':
@ -40,6 +41,12 @@ class odsreg(
ensure => present,
}
# for the local wsgi app
file { '/var/www/odsreg':
ensure => directory,
mode => '0755',
}
# for our data storage
file { '/var/lib/odsreg':
ensure => directory,
@ -51,15 +58,19 @@ class odsreg(
# a plain git checkout
vcsrepo { '/opt/odsreg':
ensure => present,
ensure => latest,
provider => git,
revision => 'master',
source => 'https://git.openstack.org/openstack-infra/odsreg',
}
# "install" a copy of it
file { '/usr/local/odsreg':
ensure => directory,
}
# "install" a copy of it
file { '/usr/local/odsreg/odsreg':
ensure => directory,
owner => 'root',
group => 'root',
source => '/opt/odsreg',
@ -87,4 +98,19 @@ class odsreg(
],
}
file { '/var/www/odsreg/django.wsgi':
ensure => present,
source => 'puppet:///modules/odsreg/django.wsgi',
mode => '0555',
owner => 'root',
group => 'root',
}
::httpd::vhost { $vhost_name:
port => 80,
priority => '50',
docroot => 'MEANINGLESS_ARGUMENT',
template => 'odsreg/odsreg.vhost.erb',
}
}

28
templates/odsreg.vhost.erb

@ -0,0 +1,28 @@
<VirtualHost *:80>
ServerName <%= scope.lookupvar("odsreg::vhost_name") %>
WSGIScriptAlias / /var/www/odsreg/django.wsgi
Alias /media/ /usr/local/odsreg/cfp/static/
Alias /static/admin/ /usr/share/pyshared/django/contrib/admin/media/
<Directory /usr/share/pyshared/django/contrib/admin/media>
Order deny,allow
Allow from all
</Directory>
<Directory /usr/local/odsreg/cfp/static/>
Order deny,allow
Allow from all
</Directory>
<Directory /var/www/odsreg>
Order deny,allow
Allow from all
</Directory>
ErrorLog /var/log/<%= scope.lookupvar("httpd::params::apache_name") %>/odsreg_error.log
LogLevel warn
CustomLog /var/log/<%= scope.lookupvar("httpd::params::apache_name") %>/odsreg_access.log combined
ServerSignature Off
</VirtualHost>
Loading…
Cancel
Save