Permalink
Browse files

Add support for ensure on apache2::site

  • Loading branch information...
1 parent b6ff484 commit a11659fce31ebe5157c454499245a1551bc913c7 @albanpeignier albanpeignier committed Mar 19, 2012
Showing with 40 additions and 23 deletions.
  1. +40 −23 manifests/definitions/site.pp
View
63 manifests/definitions/site.pp
@@ -1,32 +1,49 @@
-define apache2::site($link = '', $source = '', $content = false) {
- $real_source = $source ? {
- '' => "puppet:///files/apache2/sites-available/$name",
- default => $source
- }
+define apache2::site($link = '', $source = '', $content = false, $ensure = 'present') {
+ if $ensure == 'present' {
+ $real_source = $source ? {
+ '' => "puppet:///files/apache2/sites-available/$name",
+ default => $source
+ }
+
+ # install and enable a given site configuration
+ if $content {
+ file { "/etc/apache2/sites-available/$name":
+ content => $content,
+ notify => Service[apache2],
+ require => Package[apache2]
+ }
+ } else {
+ file { "/etc/apache2/sites-available/$name":
+ source => $real_source,
+ notify => Service[apache2],
+ require => Package[apache2],
+ links => follow
+ }
+ }
- # install and enable a given site configuration
- if $content {
+ file {
+ $link ? {
+ '' => "/etc/apache2/sites-enabled/$name",
+ default => "/etc/apache2/sites-enabled/$link"
+ } :
+ ensure => "/etc/apache2/sites-available/$name",
+ require => File["/etc/apache2/sites-available/$name"],
+ notify => Service[apache2]
+ }
+ } else {
file { "/etc/apache2/sites-available/$name":
- content => $content,
+ ensure => $ensure,
notify => Service[apache2],
require => Package[apache2]
}
- } else {
- file { "/etc/apache2/sites-available/$name":
- source => $real_source,
+ file {
+ $link ? {
+ '' => "/etc/apache2/sites-enabled/$name",
+ default => "/etc/apache2/sites-enabled/$link"
+ } :
+ ensure => $ensure,
notify => Service[apache2],
- require => Package[apache2],
- links => follow
+ require => Package[apache2]
}
}
-
- file {
- $link ? {
- '' => "/etc/apache2/sites-enabled/$name",
- default => "/etc/apache2/sites-enabled/$link"
- } :
- ensure => "/etc/apache2/sites-available/$name",
- require => File["/etc/apache2/sites-available/$name"],
- notify => Service[apache2]
- }
}

0 comments on commit a11659f

Please sign in to comment.