summaryrefslogtreecommitdiff
path: root/manifests/config
diff options
context:
space:
mode:
authorGabriel Filion <lelutin@gmail.com>2011-09-19 15:11:32 -0400
committerGabriel Filion <lelutin@gmail.com>2011-12-09 10:34:18 -0500
commit08f6c9b218893ea94b3611d687a56090e7fea5b2 (patch)
tree8061989c9544091f9dc33a64396d0a4e65eaf9d7 /manifests/config
parenta51e1de81e1200751613216ab7a074e82a5dc1c8 (diff)
config: Implement config files as links
Some packages in Debian manage an Apache config file in their own /etc directory and create a link to that file in Apache's conf.d directory. One example package that does this is nagios3. Introduce a new argument, $target, that can be used to specify the link destination. When using $target, the value to $ensure must also be 'link' to make the file into a symbolic link. This is to make it explicit when we want the apache::config::file to behave differently than the normal behaviour of creating a plain text file in conf.d. Signed-off-by: Gabriel Filion <lelutin@gmail.com>
Diffstat (limited to 'manifests/config')
-rw-r--r--manifests/config/file.pp51
-rw-r--r--manifests/config/global.pp2
-rw-r--r--manifests/config/include.pp2
3 files changed, 34 insertions, 21 deletions
diff --git a/manifests/config/file.pp b/manifests/config/file.pp
index 697b69a..ca741de 100644
--- a/manifests/config/file.pp
+++ b/manifests/config/file.pp
@@ -2,6 +2,7 @@
# by default we assume it's a global configuration file
define apache::config::file(
$ensure = present,
+ $target = false,
$type = 'global',
$source = 'absent',
$content = 'absent',
@@ -29,28 +30,36 @@ define apache::config::file(
notify => Service[apache],
owner => root, group => 0, mode => 0644;
}
- case $content {
- 'absent': {
- $real_source = $source ? {
- 'absent' => [
- "puppet://${server}/modules/site-apache/${confdir}/${fqdn}/${name}",
- "puppet://${server}/modules/site-apache/${confdir}/${apache_cluster_node}/${name}",
- "puppet://${server}/modules/site-apache/${confdir}/${operatingsystem}.${lsbdistcodename}/${name}",
- "puppet://${server}/modules/site-apache/${confdir}/${operatingsystem}/${name}",
- "puppet://${server}/modules/site-apache/${confdir}/${name}",
- "puppet://${server}/modules/apache/${confdir}/${operatingsystem}.${lsbdistcodename}/${name}",
- "puppet://${server}/modules/apache/${confdir}/${operatingsystem}/${name}",
- "puppet://${server}/modules/apache/${confdir}/${name}"
- ],
- default => $source,
- }
- File["apache_${name}"]{
- source => $real_source,
- }
+
+ if ($ensure == 'link') and ($target != false) {
+ File["apache_${name}"] {
+ target => $target,
}
- default: {
- File["apache_${name}"]{
- content => $content,
+ }
+ else {
+ case $content {
+ 'absent': {
+ $real_source = $source ? {
+ 'absent' => [
+ "puppet://${server}/modules/site-apache/${confdir}/${fqdn}/${name}",
+ "puppet://${server}/modules/site-apache/${confdir}/${apache_cluster_node}/${name}",
+ "puppet://${server}/modules/site-apache/${confdir}/${operatingsystem}.${lsbdistcodename}/${name}",
+ "puppet://${server}/modules/site-apache/${confdir}/${operatingsystem}/${name}",
+ "puppet://${server}/modules/site-apache/${confdir}/${name}",
+ "puppet://${server}/modules/apache/${confdir}/${operatingsystem}.${lsbdistcodename}/${name}",
+ "puppet://${server}/modules/apache/${confdir}/${operatingsystem}/${name}",
+ "puppet://${server}/modules/apache/${confdir}/${name}"
+ ],
+ default => $source,
+ }
+ File["apache_${name}"]{
+ source => $real_source,
+ }
+ }
+ default: {
+ File["apache_${name}"]{
+ content => $content,
+ }
}
}
}
diff --git a/manifests/config/global.pp b/manifests/config/global.pp
index 5bb075b..8b0389b 100644
--- a/manifests/config/global.pp
+++ b/manifests/config/global.pp
@@ -2,12 +2,14 @@
# wrapper for apache::config::file
define apache::config::global(
$ensure = present,
+ $target = false,
$source = 'absent',
$content = 'absent',
$destination = 'absent'
){
apache::config::file { "${name}":
ensure => $ensure,
+ target => $target,
type => 'global',
source => $source,
content => $content,
diff --git a/manifests/config/include.pp b/manifests/config/include.pp
index b58073f..4d676f0 100644
--- a/manifests/config/include.pp
+++ b/manifests/config/include.pp
@@ -1,12 +1,14 @@
# deploy apache configuration file (includes for vhosts)
define apache::config::include(
$ensure = present,
+ $target = false,
$source = 'absent',
$content = 'absent',
$destination = 'absent'
){
apache::config::file { "${name}":
ensure => $ensure,
+ target => $target,
type => 'include',
source => $source,
content => $content,