OLD | NEW |
| (Empty) |
1 # == Type: adblockplus::host | |
2 # | |
3 # Manage host information for any node within the Adblock Plus infrastructure. | |
4 # | |
5 # === Parameters: | |
6 # | |
7 # [*ensure*] | |
8 # Whether to ensure any host-related resources being 'present' or 'absent'. | |
9 # Note that implicit realization of embedded resources only takes place if | |
10 # $ensure is 'absent'. | |
11 # | |
12 # [*fqdn*] | |
13 # The fully qualified domain name associated with the host. See the examples | |
14 # section below on how this piece of information is supposed to be re-used. | |
15 # | |
16 # [*groups*] | |
17 # A list of logical groups the host is associated with, i.e. for direct or | |
18 # indirect translation into nagios_hostgroup names or similar. This parameter | |
19 # is considered meta-information and not processed by type adblockplus::host. | |
20 # | |
21 # [*ips*] | |
22 # A list of one or more IPv4 and IPv6 addresses associated with the host, | |
23 # the first one of which is considered the primary IP address, and each of | |
24 # which is included as $alias in the (virtual) Sshkey[$title] resource. | |
25 # | |
26 # [*public_key*] | |
27 # The host's public (SSH) key, i.e "ssh-rsa AA.... host1.example.com", for | |
28 # use with the (virual) Sshkey[$title] resource. Note that this implies the | |
29 # default public key of the host being used, namely the first one offered | |
30 # during the SSL handshake. | |
31 # | |
32 # [*role*] | |
33 # The name of the host's primary role, if any. This parameter is considered | |
34 # meta-information and not processed by type adblockplus::host. | |
35 # | |
36 # === Examples: | |
37 # | |
38 # # Hosts being 'present' do not imply realization of embedded resources | |
39 # adblockplus::host {'node1': | |
40 # ensure => 'present', | |
41 # ips => ['10.8.0.1'], | |
42 # } | |
43 # | |
44 # # Explicit realization of /etc/hosts and /etc/ssh/ssh_known_hosts records | |
45 # realize(Host['node1']) | |
46 # realize(Sshkey['node1']) | |
47 # | |
48 # # Global realization, i.e. when creating a node all others can access | |
49 # realize(Host<|tag == 'adblockplus::host'|>) | |
50 # realize(Sshkey<|tag == 'adblockplus::host'|>) | |
51 # | |
52 # # Addressing (meta-) parameters for re-using their values | |
53 # $fqdn = getparam(Adblockplus::Host['node1'], 'fqdn') | |
54 # $primary_ip = getparam(Host['node1'], 'ip') | |
55 # $key_type = getparam(Sshkey['node1'], 'type') | |
56 # | |
57 define adblockplus::host ( | |
58 $ensure = 'present', | |
59 $fqdn = "$name.$adblockplus::authority", | |
60 $groups = [], | |
61 $ips, | |
62 $public_key = undef, | |
63 $role = undef, | |
64 ) { | |
65 | |
66 include adblockplus | |
67 include stdlib | |
68 | |
69 case $public_key { | |
70 | |
71 undef: { | |
72 $sshkey_ensure = 'absent' | |
73 $sshkey_key = undef | |
74 $sshkey_type = undef | |
75 } | |
76 | |
77 default: { | |
78 $sshkey_ensure = $ensure | |
79 $sshkey = split($public_key, '\s+') | |
80 $sshkey_type = $sshkey[0] | |
81 $sshkey_key = $sshkey[1] | |
82 } | |
83 } | |
84 | |
85 @host {$title: | |
86 ensure => $ensure, | |
87 ip => pick($ips), | |
88 name => $fqdn, | |
89 tag => ['adblockplus::host'], | |
90 } | |
91 | |
92 @sshkey {$title: | |
93 ensure => $sshkey_ensure, | |
94 host_aliases => $ips, | |
95 key => $sshkey_key, | |
96 name => $fqdn, | |
97 require => File['/etc/ssh/ssh_known_hosts'], | |
98 tag => ['adblockplus::host'], | |
99 type => $sshkey_type, | |
100 } | |
101 | |
102 if $ensure == 'absent' { | |
103 realize(Host[$title]) | |
104 realize(Sshkey[$title]) | |
105 } | |
106 | |
107 if $::role != undef and manifest_exists("adblockplus::host::$::role") { | |
108 ensure_resource("adblockplus::host::$::role", $title, {name => $name}) | |
109 } | |
110 } | |
OLD | NEW |