summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--manifests/init.pp52
-rw-r--r--templates/error.erb2
2 files changed, 30 insertions, 24 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"],
}
}
diff --git a/templates/error.erb b/templates/error.erb
index 5e2cf5f..fef5dd7 100644
--- a/templates/error.erb
+++ b/templates/error.erb
@@ -5,7 +5,7 @@
DocumentRoot <%= apache_error_folder %>
ErrorDocument 404 <%= apache_error_dest %>
- <Directory /var/www/error>
+ <Directory <%= apache_error_folder %>>
DirectoryIndex index.html
Options Indexes -Includes FollowSymLinks -MultiViews
AllowOverride None