From 8751ab870047dadcbc48a5e21708274e2600399e Mon Sep 17 00:00:00 2001 From: Michael Scherer Date: Sat, 6 Nov 2010 17:50:14 +0000 Subject: - add django support with wsgi --- modules/apache/manifests/init.pp | 33 ++++++++++++++++++++++++++ modules/apache/templates/django.wsgi | 9 +++++++ modules/apache/templates/vhost_django_app.conf | 12 ++++++++++ 3 files changed, 54 insertions(+) create mode 100644 modules/apache/templates/django.wsgi create mode 100644 modules/apache/templates/vhost_django_app.conf (limited to 'modules/apache') 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 @@ + + ServerName <%= name %> + # Serve static content directly + DocumentRoot /dev/null + + WSGIScriptAlias / <%= wsgi_dir%>/<%= name %>.wsgi + + + Allow from all + + + -- cgit v1.2.1