b27b7ed6166bad6f20ea90db16a3c56a10a681c4
[mirror/dsa-puppet.git] / modules / postgres / manifests / backup_server / register_backup_clienthost.pp
1 #
2 define postgres::backup_server::register_backup_clienthost (
3   $sshpubkey = $::postgres_key,
4   $ipaddrlist = join(getfromhash($deprecated::nodeinfo, 'ldap', 'ipHostNumber'), ","),
5   $hostname = $::hostname,
6 ) {
7   include postgres::backup_server::globals
8
9   $ssh_command = "/usr/local/bin/debbackup-ssh-wrap ${::hostname}"
10
11   ssh::authorized_key_add { 'register_backup_clienthost':
12     target_user => $postgres::backup_server::globals::backup_unix_user,
13     key         => dig($facts, 'ssh_keys_users', 'postgres', 'id_rsa.pub', 'line'),
14     command     => $ssh_command,
15     from        => $base::public_addresses,
16     collect_tag => $postgres::backup_server::globals::tag_source_sshkey,
17   }
18
19   if $sshpubkey {
20     $addr = assert_type(String[1], $ipaddrlist)
21     @@concat::fragment { "postgresql::server::backup-source-clienthost::$name::$fqdn":
22       target => $postgres::backup_server::globals::sshkeys_sources ,
23       content  => @("EOF"),
24           ${hostname} ${addr} ${sshpubkey}
25           | EOF
26       tag     => $postgres::backup_server::globals::tag_source_sshkey,
27     }
28   }
29 }