diff --git a/README b/README index 11d9314..8c55aea 100644 --- a/README +++ b/README @@ -44,7 +44,9 @@ definitions -- so simply including them in a node definition won't work... * `ensure`: typically set to "present" or "absent", but any value legal for a file resource can be used. Defaults to "present" * `content`: set this to the text of the snippet -- eg, through -template(). Defaults to `template("apache2/$name.conf.erb")`, which is +template(). If set to "source_file", the file's content will be sourced from +puppet master's puppet:///files/apache2/${fqdn}/${name}.conf or puppet:///files/apache2/${name}.conf, +whichever is available first. Defaults to `template("apache2/$name.conf.erb")`, which is unlikely to be what you want. * `order`: specifies the load order for this config snippet. the snippet will end up in `/etc/apache2/conf.d/$order-$name.conf`, and apache will load @@ -77,7 +79,9 @@ remove the package, even if ensure is set to absent. before evaluating the rest of the site definition. It does not currently remove the package, even if ensure is set to absent. * `content`: set this to the text of the site definition -- eg, through -template(). If unset, the module will simply ensure that a file named +template(). If set to "source_file", the file's content will be sourced from +puppet master's puppet:///files/apache2/${fqdn}/${name} or puppet:///files/apache2/${name}, +whichever is available first. If unset, the module will simply ensure that a file named "/etc/apache2/sites-available/$name" exists ## Example ## diff --git a/manifests/init.pp b/manifests/init.pp index ca22a7c..c27a63c 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -118,19 +118,45 @@ # Define an apache2 config snippet. Places all config snippets into # /etc/apache2/conf.d, where they will be automatically loaded define config ( $ensure = 'present', $content = '', $order="500") { - $real_content = $content ? { '' => template("apache2/${name}.conf.erb"), - default => $content, - } - - file { "${apache_conf}/${order}-${name}.conf": - ensure => $ensure, - content => $content, - mode => 644, - owner => root, - group => root, - # given the way File[$apache_conf] is defined, this might lead to - # multiple restarts. not sure. - notify => Exec["reload-apache2"], + case $content { + '': { + file { "${apache_conf}/${order}-${name}.conf": + ensure => $ensure, + content => template("apache2/${name}.conf.erb"), + mode => 644, + owner => root, + group => root, + # given the way File[$apache_conf] is defined, this might lead to + # multiple restarts. not sure. + notify => Exec["reload-apache2"], + } + } + + 'source_file': { + file { "${apache_conf}/${order}-${name}.conf": + source => [ "puppet:///files/apache2/${fqdn}/${name}.conf", "puppet:///files/apache2/${name}.conf" ], + ensure => $ensure, + mode => 644, + owner => root, + group => root, + # given the way File[$apache_conf] is defined, this might lead to + # multiple restarts. not sure. + notify => Exec["reload-apache2"], + } + } + + default: { + file { "${apache_conf}/${order}-${name}.conf": + ensure => $ensure, + content => template("apache2/${name}.conf.erb"), + mode => 644, + owner => root, + group => root, + # given the way File[$apache_conf] is defined, this might lead to + # multiple restarts. not sure. + notify => Exec["reload-apache2"], + } + } } } @@ -179,6 +205,17 @@ } } + 'source_file': { + file { "${apache_sites}-available/${name}": + source => [ "puppet:///files/apache2/${fqdn}/${name}", "puppet:///files/apache2/${name}" ], + mode => 644, + owner => root, + group => root, + ensure => present, + alias => "site-$name", + } + } + default: { file { "${apache_sites}-available/${name}": content => $content,