diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2009-11-05 15:39:01 -0200 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2009-11-05 15:39:01 -0200 |
commit | 91fe806a05f6add611459c0be755cfcf50ea1d90 (patch) | |
tree | 889767b540a6fbf9098df3f056c87632ddeb9699 | |
parent | 5c65d2ab6dc43f5ce37ff8975346d52f4258859c (diff) | |
download | puppet-apache-91fe806a05f6add611459c0be755cfcf50ea1d90.tar.gz puppet-apache-91fe806a05f6add611459c0be755cfcf50ea1d90.tar.bz2 |
Adding more configuration into VirtualHost definition
-rw-r--r-- | manifests/init.pp | 14 | ||||
-rw-r--r-- | templates/website.erb | 20 |
2 files changed, 27 insertions, 7 deletions
diff --git a/manifests/init.pp b/manifests/init.pp index 7ec5169..3c5caf8 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -21,8 +21,6 @@ # TODO: log level, log files, etc # TODO: better variable names, enable value overwriting -$apache_sites_folder = '/var/users/home'; -$apache_www_folder = '/var/www/sarava'; class apache { @@ -51,8 +49,18 @@ class apache { notify => Service["apache"], } + # prepare variables to use in templates + case $apache_sites_folder { + '': { $apache_sites_folder = '/var/www/sites' } + } + + case $apache_www_folder { + '': { $apache_www_folder= '/var/www' } + } + # TODO: ensure folders exist with right modes and ownership - define website($ensure = present, $alias = [], $use = []) { + define website($ensure = present, $docroot = false, $redirect = false, + $protocol = 'http', $alias = false, $use = false) { file { "/etc/apache2/sites-available/$title": ensure => $ensure, content => template('apache/website.erb'), diff --git a/templates/website.erb b/templates/website.erb index 56be471..156b4b1 100644 --- a/templates/website.erb +++ b/templates/website.erb @@ -1,6 +1,18 @@ -# begin vhost for <%= $title %> +# begin vhost for <%= title %> <VirtualHost *:80> - # TODO - ServerName <%= $title %>.<%= $domain %> + ServerName <%= title %>.<%= domain %> +<% if alias != false %> + ServerAlias <%= alias %> +<% end %> + DocumentRoot <%= docroot %> +<% if redirect != false %> + RedirectMatch ^/$ <%= protocol %>://<%= title %>.<%= domain %>/<%= redirect %> +<% end %> + +<% if use != false %> + <% use.each do |instance| -%> + Use <%= instance %> + <% end -%> +<% end -%> </VirtualHost> -# end vhost for <%= $title %> +# end vhost for <%= title %> |