diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2009-12-29 14:44:35 -0200 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2009-12-29 14:44:35 -0200 |
commit | 1e5db440c4fa2412b0346b3f1d4b6714943cff16 (patch) | |
tree | d366b875a4732dfb8f76dae821802e2ac25e6767 /manifests | |
parent | d85df83c88cd69c14c055862060a96f7900fea0c (diff) | |
download | puppet-apache-1e5db440c4fa2412b0346b3f1d4b6714943cff16.tar.gz puppet-apache-1e5db440c4fa2412b0346b3f1d4b6714943cff16.tar.bz2 |
Adding template and filename parameters
Diffstat (limited to 'manifests')
-rw-r--r-- | manifests/init.pp | 52 |
1 files changed, 29 insertions, 23 deletions
diff --git a/manifests/init.pp b/manifests/init.pp index cd82d38..6d8e5d4 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -95,24 +95,29 @@ class apache { define site($ensure = present, $docroot = false, $redirect = false, $redirect_match = false, $protocol = 'http', $server_alias = false, $use = false, $ticket = false, - $source = false) { + $source = false, $template = 'apache/site.erb', $filename = '') { + + $vhost = $filename ? { + '' => "$title", + default => "$filename", + } case $source { true: { - file { "${apache2_sites}-available/$title": - ensure => $ensure, - source => "puppet://$server/files/apache/vhosts/$title", - owner => root, - group => root, - mode => 0644, - require => File["${apache2_macros}"], - notify => Service["apache"], - } + file { "${apache2_sites}-available/$vhost": + ensure => $ensure, + source => "puppet://$server/files/apache/vhosts/$title", + owner => root, + group => root, + mode => 0644, + require => File["${apache2_macros}"], + notify => Service["apache"], } + } false: { - file { "${apache2_sites}-available/$title": + file { "${apache2_sites}-available/$vhost": ensure => $ensure, - content => template('apache/site.erb'), + content => template("$template"), owner => root, group => root, mode => 0644, @@ -122,12 +127,13 @@ class apache { } } - $status = $ensure ? { - 'present' => "${apache2_sites}-available/$title", - default => 'absent', - } - # Enable the site without a2ensite + # + #$status = $ensure ? { + # 'present' => "${apache2_sites}-available/$vhost", + # default => 'absent', + #} + # #file { "/etc/apache2/sites-enabled/$title": # ensure => $status, # owner => root, @@ -157,16 +163,16 @@ class apache { } } } - exec { "/usr/sbin/a2ensite $name": - unless => "/bin/sh -c '[ -L ${apache2_sites}-enabled/$name ] \ - && [ ${apache2_sites}-enabled/$name -ef ${apache2_sites}-available/$name ]'", + exec { "/usr/sbin/a2ensite $vhost": + unless => "/bin/sh -c '[ -L ${apache2_sites}-enabled/$vhost ] \ + && [ ${apache2_sites}-enabled/$vhost -ef ${apache2_sites}-available/$vhost ]'", notify => Exec["reload-apache2"], } } 'absent': { - exec { "/usr/sbin/a2dissite $name": - onlyif => "/bin/sh -c '[ -L ${apache2_sites}-enabled/$name ] \ - && [ ${apache2_sites}-enabled/$name -ef ${apache2_sites}-available/$name ]'", + exec { "/usr/sbin/a2dissite $vhost": + onlyif => "/bin/sh -c '[ -L ${apache2_sites}-enabled/$vhost ] \ + && [ ${apache2_sites}-enabled/$vhost -ef ${apache2_sites}-available/$vhost ]'", notify => Exec["reload-apache2"], } } |