diff options
author | Michael Scherer <misc@mageia.org> | 2011-02-01 12:44:50 +0000 |
---|---|---|
committer | Michael Scherer <misc@mageia.org> | 2011-02-01 12:44:50 +0000 |
commit | 0504e572eec2cc6e23b43c21d84efbe21b323faa (patch) | |
tree | 900ec2202e17ef5edab6dba1e64ffa541ed1d4d6 /modules | |
parent | f4788d42dda16c6bdc99c76e9969ad59f2e1bb88 (diff) | |
download | puppet-0504e572eec2cc6e23b43c21d84efbe21b323faa.tar puppet-0504e572eec2cc6e23b43c21d84efbe21b323faa.tar.gz puppet-0504e572eec2cc6e23b43c21d84efbe21b323faa.tar.bz2 puppet-0504e572eec2cc6e23b43c21d84efbe21b323faa.tar.xz puppet-0504e572eec2cc6e23b43c21d84efbe21b323faa.zip |
- refactoring of apache config file, to ease future deployment
Diffstat (limited to 'modules')
-rw-r--r-- | modules/apache/manifests/init.pp | 89 | ||||
-rw-r--r-- | modules/apache/templates/vhost_base.conf | 23 | ||||
-rw-r--r-- | modules/apache/templates/vhost_catalyst_app.conf | 33 | ||||
-rw-r--r-- | modules/apache/templates/vhost_django_app.conf | 26 | ||||
-rw-r--r-- | modules/apache/templates/vhost_reverse_proxy.conf | 12 | ||||
-rw-r--r-- | modules/apache/templates/vhost_ssl_redirect.conf | 5 |
6 files changed, 66 insertions, 122 deletions
diff --git a/modules/apache/manifests/init.pp b/modules/apache/manifests/init.pp index 8c6daa74..f929c303 100644 --- a/modules/apache/manifests/init.pp +++ b/modules/apache/manifests/init.pp @@ -96,65 +96,60 @@ class apache { } } - define vhost_redirect_ssl() { - file { "redirect_ssl_$name.conf": - path => "/etc/httpd/conf/vhosts.d/redirect_ssl_$name.conf", - ensure => "present", - owner => root, - group => root, - mode => 644, - notify => Service['apache'], - content => template("apache/vhost_ssl_redirect.conf") + define vhost_base($content = '', + $location = '/dev/null', + $use_ssl = false, + $vhost = false) { + if ! $vhost { + $real_vhost = $name + } else { + $real_vhost = $vhost } - } - - define vhost_catalyst_app($script, $location = '', $process = 4, $use_ssl = false) { - - include apache::mod_fastcgi if $use_ssl { include apache::mod_ssl openssl::self_signed_cert{ "$name": directory => "/etc/ssl/apache/", - before => File["$name.conf"], + before => File["$filename"], } } - file { "$name.conf": - path => "/etc/httpd/conf/vhosts.d/$name.conf", + $filename = "$name.conf" + file { "$filename": + path => "/etc/httpd/conf/vhosts.d/$filename", ensure => "present", owner => root, group => root, mode => 644, notify => Service['apache'], + content => template("apache/vhost_base.conf") + } + } + + define vhost_redirect_ssl() { + vhost_base { "redirect_ssl_$name": + vhost => $name, + content => template("apache/vhost_ssl_redirect.conf") + } + } + + define vhost_catalyst_app($script, $location = '', $process = 4, $use_ssl = false) { + + include apache::mod_fastcgi + vhost_base { $name: + use_ssl => $use_ssl, content => template("apache/vhost_catalyst_app.conf") } } define vhost_django_app($module = false, $module_path = false, $use_ssl = false) { include apache::mod_wsgi - - if $use_ssl { - include apache::mod_ssl - openssl::self_signed_cert{ "$name": - directory => "/etc/ssl/apache/", - before => File["$name.conf"], - } + vhost_base { $name: + content => template("apache/vhost_django_app.conf") } - + # module is a ruby reserved keyword, cannot be used in templates $django_module = $module - file { "$name.conf": - path => "/etc/httpd/conf/vhosts.d/$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 => "/usr/local/lib/wsgi/$name.wsgi", ensure => "present", @@ -194,28 +189,16 @@ class apache { define vhost_simple($location) { include apache::base - file { "$name.conf": - path => "/etc/httpd/conf/vhosts.d/$name.conf", - ensure => "present", - owner => root, - group => root, - mode => 644, - notify => Service['apache'], - content => template("apache/vhost_simple.conf") - } + vhost_base { $name: + location => $location, + } } define vhost_reverse_proxy($url) { include apache::mod_proxy - file { "$name.conf": - path => "/etc/httpd/conf/vhosts.d/$name.conf", - ensure => "present", - owner => root, - group => root, - mode => 644, - notify => Service['apache'], + vhost_base { $name: content => template("apache/vhost_reverse_proxy.conf") - } + } } define webapp_other($webapp_file) { diff --git a/modules/apache/templates/vhost_base.conf b/modules/apache/templates/vhost_base.conf new file mode 100644 index 00000000..266e7c29 --- /dev/null +++ b/modules/apache/templates/vhost_base.conf @@ -0,0 +1,23 @@ +<%- if use_ssl then + port = 443 +else + port = 80 +end +-%> + +<VirtualHost *:<%= port %>> +<%- if use_ssl then -%> + SSLEngine on + SSLCertificateFile /etc/ssl/apache/<%= name %>.pem + SSLCertificateKeyFile /etc/ssl/apache/<%= name %>.pem +<%- end -%> + ServerName <%= real_vhost %> + DocumentRoot <%= location %> + + <%= content %> + + <Location /> + Allow from all + </Location> +</VirtualHost> + diff --git a/modules/apache/templates/vhost_catalyst_app.conf b/modules/apache/templates/vhost_catalyst_app.conf index ca0aca68..eaa652d7 100644 --- a/modules/apache/templates/vhost_catalyst_app.conf +++ b/modules/apache/templates/vhost_catalyst_app.conf @@ -1,28 +1,5 @@ -<% if use_ssl then - port = 443 -else - port = 80 -end -%> - -<VirtualHost *:<%= port %>> -<% if use_ssl then %> - SSLEngine on - SSLCertificateFile /etc/ssl/apache/<%= name %>.pem - SSLCertificateKeyFile /etc/ssl/apache/<%= name %>.pem -<% end %> - ServerName <%= name %> - # Serve static content directly - DocumentRoot /dev/null - -<% if location != '' then %> - Alias /static <%= location %>/root/static -<% end %> - Alias / <%= script %>/ - FastCgiServer <%= script %> -processes <%= process %> -idle-timeout 30 - - <Location /> - Allow from all - </Location> -</VirtualHost> - +<%- if location != '' then -%> +Alias /static <%= location %>/root/static +<%- end -%> +Alias / <%= script %>/ +FastCgiServer <%= script %> -processes <%= process %> -idle-timeout 30 diff --git a/modules/apache/templates/vhost_django_app.conf b/modules/apache/templates/vhost_django_app.conf index 1cc12458..3310045e 100644 --- a/modules/apache/templates/vhost_django_app.conf +++ b/modules/apache/templates/vhost_django_app.conf @@ -1,25 +1 @@ -<% if use_ssl then - port = 443 -else - port = 80 -end -%> - -<VirtualHost *:<%= port %>> -<% if use_ssl then %> - SSLEngine on - SSLCertificateFile /etc/ssl/apache/<%= name %>.pem - SSLCertificateKeyFile /etc/ssl/apache/<%= name %>.pem -<% end %> - - ServerName <%= name %> - # Serve static content directly - DocumentRoot /dev/null - - WSGIScriptAlias / /usr/local/lib/wsgi/<%= name %>.wsgi -#footer - <Location /> - Allow from all - </Location> -</VirtualHost> - +WSGIScriptAlias / /usr/local/lib/wsgi/<%= name %>.wsgi diff --git a/modules/apache/templates/vhost_reverse_proxy.conf b/modules/apache/templates/vhost_reverse_proxy.conf index 24c2d12b..94866be5 100644 --- a/modules/apache/templates/vhost_reverse_proxy.conf +++ b/modules/apache/templates/vhost_reverse_proxy.conf @@ -1,10 +1,3 @@ -<VirtualHost *:80> - ServerName <%= name %> - # Serve static content directly - DocumentRoot /dev/null - - - ProxyRequests Off <Proxy *> @@ -15,8 +8,3 @@ ProxyPass / <%= url %> ProxyPassReverse / <%= url %> - <Location /> - Allow from all - </Location> -</VirtualHost> - diff --git a/modules/apache/templates/vhost_ssl_redirect.conf b/modules/apache/templates/vhost_ssl_redirect.conf index bb22a2c8..d13c3093 100644 --- a/modules/apache/templates/vhost_ssl_redirect.conf +++ b/modules/apache/templates/vhost_ssl_redirect.conf @@ -1,4 +1 @@ -<VirtualHost *:80> - ServerName <%= name %> - Redirect / https://<%= name %>/ -</VirtualHost> +Redirect / https://<%= name %>/ |