aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/base_installation/lib/puppet/parser/functions/find_host.rb18
-rw-r--r--modules/role/manifests/backup/postgresql.pp10
2 files changed, 27 insertions, 1 deletions
diff --git a/modules/base_installation/lib/puppet/parser/functions/find_host.rb b/modules/base_installation/lib/puppet/parser/functions/find_host.rb
new file mode 100644
index 0000000..79aae5c
--- /dev/null
+++ b/modules/base_installation/lib/puppet/parser/functions/find_host.rb
@@ -0,0 +1,18 @@
1module Puppet::Parser::Functions
2 newfunction(:find_host, :type => :rvalue, :doc => <<-EOS
3This function searches through the hosts to find the one with matching cn
4 EOS
5 ) do |arguments|
6
7 if (arguments.size != 2) then
8 raise(Puppet::ParseError, "grep(): Wrong number of arguments given #{arguments.size} for 2")
9 end
10
11 hosts = arguments[0]
12 cn = arguments[1]
13
14 hosts.find { |host| host["cn"].any? { |cn_| cn_ == cn } }
15 end
16end
17
18# vim: set ts=2 sw=2 et :
diff --git a/modules/role/manifests/backup/postgresql.pp b/modules/role/manifests/backup/postgresql.pp
index e891195..b26773c 100644
--- a/modules/role/manifests/backup/postgresql.pp
+++ b/modules/role/manifests/backup/postgresql.pp
@@ -94,7 +94,15 @@ class role::backup::postgresql inherits role::backup {
94 } 94 }
95 } 95 }
96 96
97 $pg_backup_hosts.each |$pg_backup_host, $pg_infos| { 97 $pg_backup_hosts.each |$backup_host_cn, $pg_infos| {
98 $host = find_host($facts["ldapvar"]["other"], $backup_host_cn)
99 if empty($host) {
100 $pg_backup_host = $backup_host_cn
101 } elsif has_key($host["vars"], "host") {
102 $pg_backup_host = $host["vars"]["host"][0]
103 } else {
104 $pg_backup_host = $host["vars"]["real_hostname"][0]
105 }
98 $pg_path = "$mountpoint/$pg_backup_host/postgresql" 106 $pg_path = "$mountpoint/$pg_backup_host/postgresql"
99 $pg_backup_path = "$mountpoint/$pg_backup_host/postgresql_backup" 107 $pg_backup_path = "$mountpoint/$pg_backup_host/postgresql_backup"
100 $pg_host = "$pg_backup_host" 108 $pg_host = "$pg_backup_host"