OLD | NEW |
1 # == Type: adblockplus::host | 1 # == Type: adblockplus::host |
2 # | 2 # |
3 # Manage host information for any node within the Adblock Plus infrastructure. | 3 # Manage host information for any node within the Adblock Plus infrastructure. |
4 # | 4 # |
5 # === Parameters: | 5 # === Parameters: |
6 # | 6 # |
7 # [*ensure*] | 7 # [*ensure*] |
8 # Whether to ensure any host-related resources being 'present' or 'absent'. | 8 # Whether to ensure any host-related resources being 'present' or 'absent'. |
9 # Note that implicit realization of embedded resources only takes place if | 9 # Note that implicit realization of embedded resources only takes place if |
10 # $ensure is 'absent'. | 10 # $ensure is 'absent'. |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 # | 51 # |
52 # # Addressing (meta-) parameters for re-using their values | 52 # # Addressing (meta-) parameters for re-using their values |
53 # $fqdn = getparam(Adblockplus::Host['node1'], 'fqdn') | 53 # $fqdn = getparam(Adblockplus::Host['node1'], 'fqdn') |
54 # $primary_ip = getparam(Host['node1'], 'ip') | 54 # $primary_ip = getparam(Host['node1'], 'ip') |
55 # $key_type = getparam(Sshkey['node1'], 'type') | 55 # $key_type = getparam(Sshkey['node1'], 'type') |
56 # | 56 # |
57 define adblockplus::host ( | 57 define adblockplus::host ( |
58 $ensure = 'present', | 58 $ensure = 'present', |
59 $fqdn = "$name.$adblockplus::authority", | 59 $fqdn = "$name.$adblockplus::authority", |
60 $groups = [], | 60 $groups = [], |
61 $ips, | 61 $ips = [], |
62 $public_key = undef, | 62 $public_key = undef, |
63 $role = undef, | 63 $role = undef, |
64 ) { | 64 ) { |
65 | 65 |
66 include adblockplus | 66 include adblockplus |
67 include stdlib | 67 include stdlib |
68 | 68 |
69 case $public_key { | 69 case $public_key { |
70 | 70 |
71 undef: { | 71 undef: { |
72 $sshkey_ensure = 'absent' | 72 $sshkey_ensure = 'absent' |
73 $sshkey_key = undef | 73 $sshkey_key = undef |
74 $sshkey_type = undef | 74 $sshkey_type = undef |
75 } | 75 } |
76 | 76 |
77 default: { | 77 default: { |
78 $sshkey_ensure = $ensure | 78 $sshkey_ensure = $ensure |
79 $sshkey = split($public_key, '\s+') | 79 $sshkey = split($public_key, '\s+') |
80 $sshkey_type = $sshkey[0] | 80 $sshkey_type = $sshkey[0] |
81 $sshkey_key = $sshkey[1] | 81 $sshkey_key = $sshkey[1] |
82 } | 82 } |
83 } | 83 } |
84 | 84 |
85 @host {$title: | 85 @host {$title: |
86 ensure => $ensure, | 86 ensure => $ensure, |
87 ip => pick($ips), | 87 ip => pick($ips[0], '0.0.0.0'), |
88 name => $fqdn, | 88 name => $fqdn, |
89 tag => ['adblockplus::host'], | 89 tag => ['adblockplus::host'], |
90 } | 90 } |
91 | 91 |
92 @sshkey {$title: | 92 @sshkey {$title: |
93 ensure => $sshkey_ensure, | 93 ensure => $sshkey_ensure, |
94 host_aliases => $ips, | 94 host_aliases => $ips, |
95 key => $sshkey_key, | 95 key => $sshkey_key, |
96 name => $fqdn, | 96 name => $fqdn, |
97 require => File['/etc/ssh/ssh_known_hosts'], | 97 require => File['/etc/ssh/ssh_known_hosts'], |
98 tag => ['adblockplus::host'], | 98 tag => ['adblockplus::host'], |
99 type => $sshkey_type, | 99 type => $sshkey_type, |
100 } | 100 } |
101 | 101 |
102 if $ensure == 'absent' { | 102 if $ensure == 'absent' { |
103 realize(Host[$title]) | 103 realize(Host[$title]) |
104 realize(Sshkey[$title]) | 104 realize(Sshkey[$title]) |
105 } | 105 } |
106 | 106 |
107 if $::role != undef and manifest_exists("adblockplus::host::$::role") { | 107 if $::role != undef and manifest_exists("adblockplus::host::$::role") { |
108 ensure_resource("adblockplus::host::$::role", $title, {name => $name}) | 108 ensure_resource("adblockplus::host::$::role", $title, {name => $name}) |
109 } | 109 } |
110 } | 110 } |
OLD | NEW |