Skip to content
This repository was archived by the owner on May 8, 2018. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 ##
Expand Down
63 changes: 50 additions & 13 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
}
}
}
}

Expand Down Expand Up @@ -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,
Expand Down