diff options
-rw-r--r-- | modules/apache/manifests/init.pp | 33 | ||||
-rw-r--r-- | modules/apache/templates/django.wsgi | 9 | ||||
-rw-r--r-- | modules/apache/templates/vhost_django_app.conf | 12 |
3 files changed, 54 insertions, 0 deletions
diff --git a/modules/apache/manifests/init.pp b/modules/apache/manifests/init.pp index 6b8f7bef..83f89088 100644 --- a/modules/apache/manifests/init.pp +++ b/modules/apache/manifests/init.pp @@ -1,6 +1,7 @@ class apache { $vhost_dir = "/etc/httpd/conf/vhosts.d" + $wsgi_dir = "/usr/local/lib/wsgi" class base { package { "apache-mpm-prefork": @@ -54,6 +55,13 @@ class apache { package { "apache-mod_wsgi": ensure => installed } + + file { $wsgi_dir: + ensure => directory, + owner => root, + group => root, + mode => 644, + } } define vhost_redirect_ssl() { @@ -82,4 +90,29 @@ class apache { content => template("apache/vhost_catalyst_app.conf") } } + + define vhost_django_app($module, $module_path = '/usr/share') { + include apache::mod_wsgi + + file { "$name.conf": + path => "$vhost_dir/$name.conf", + ensure => "present", + owner => root, + group => root, + mode => 644, + notify => Service['apache'], + content => template("apache/vhost_django_app.conf") + } + + # fichier django wsgi + file { "$name.wsgi": + path => "$wsgi_dir/$name.wsgi", + ensure => "present", + owner => root, + group => root, + mode => 755, + notify => Service['apache'], + content => template("apache/django.wsgi") + } + } } diff --git a/modules/apache/templates/django.wsgi b/modules/apache/templates/django.wsgi new file mode 100644 index 00000000..c6e19101 --- /dev/null +++ b/modules/apache/templates/django.wsgi @@ -0,0 +1,9 @@ +#!/usr/bin/python +import os, sys +sys.path.append('<%= module_path %>') +os.environ['DJANGO_SETTINGS_MODULE'] = '<%= module =%>.settings' + +import django.core.handlers.wsgi + +application = django.core.handlers.wsgi.WSGIHandler() + diff --git a/modules/apache/templates/vhost_django_app.conf b/modules/apache/templates/vhost_django_app.conf new file mode 100644 index 00000000..fffd5321 --- /dev/null +++ b/modules/apache/templates/vhost_django_app.conf @@ -0,0 +1,12 @@ +<VirtualHost *:80> + ServerName <%= name %> + # Serve static content directly + DocumentRoot /dev/null + + WSGIScriptAlias / <%= wsgi_dir%>/<%= name %>.wsgi + + <Location /> + Allow from all + </Location> +</VirtualHost> + |