aboutsummaryrefslogtreecommitdiffstats
path: root/modules/apache
diff options
context:
space:
mode:
authorMichael Scherer <misc@mageia.org>2010-11-06 17:50:14 +0000
committerMichael Scherer <misc@mageia.org>2010-11-06 17:50:14 +0000
commit8751ab870047dadcbc48a5e21708274e2600399e (patch)
tree4cedeac7a6035dfe5a555af14dab796c88f9fb1e /modules/apache
parenta4e64977303b0318a83e30569271c91bf27b7fd7 (diff)
downloadpuppet-8751ab870047dadcbc48a5e21708274e2600399e.tar
puppet-8751ab870047dadcbc48a5e21708274e2600399e.tar.gz
puppet-8751ab870047dadcbc48a5e21708274e2600399e.tar.bz2
puppet-8751ab870047dadcbc48a5e21708274e2600399e.tar.xz
puppet-8751ab870047dadcbc48a5e21708274e2600399e.zip
- add django support with wsgi
Diffstat (limited to 'modules/apache')
-rw-r--r--modules/apache/manifests/init.pp33
-rw-r--r--modules/apache/templates/django.wsgi9
-rw-r--r--modules/apache/templates/vhost_django_app.conf12
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>
+