Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 class base ($authority='adblockplus.org') { | 1 class base ($zone='adblockplus.org') { |
Felix Dahlke
2015/03/03 16:43:32
Wouldn't "zone" or maybe "domain" be a more fittin
mathias
2015/03/04 12:32:37
Indeed, let's go with $zone. $domain is much to ov
| |
2 stage {'pre': before => Stage['main']} | 2 stage {'pre': before => Stage['main']} |
3 stage {'post': require => Stage['main']} | 3 stage {'post': require => Stage['main']} |
4 | 4 |
5 class {'users': | 5 class {'users': |
6 stage => 'pre', | 6 stage => 'pre', |
7 } | 7 } |
8 | 8 |
9 class {'apt': | 9 class {'apt': |
10 always_apt_update => true | 10 always_apt_update => true |
11 } | 11 } |
(...skipping 21 matching lines...) Expand all Loading... | |
33 | 33 |
34 service {'cron': | 34 service {'cron': |
35 ensure => running, | 35 ensure => running, |
36 enable => true, | 36 enable => true, |
37 } | 37 } |
38 | 38 |
39 class {'logrotate': | 39 class {'logrotate': |
40 stage => 'post' | 40 stage => 'post' |
41 } | 41 } |
42 | 42 |
43 $servers = hiera("servers") | 43 $servers = hiera('servers') |
44 create_resources(base::explicit_host_record, $servers) | 44 create_resources(base::explicit_host_record, $servers) |
45 | 45 |
46 define explicit_host_record( | 46 define explicit_host_record( |
47 $ip, | 47 $ip, |
48 $ssh_public_key = undef, | 48 $ssh_public_key = undef, |
49 $role = undef, | 49 $role = undef, |
50 $dns = undef, | 50 $dns = undef, |
51 $groups = undef, | 51 $groups = undef, |
Wladimir Palant
2015/03/03 20:00:19
This parameter is unused, why did you add it?
mathias
2015/03/04 12:32:37
It's one of the allowed keywords in hosts.yaml, an
| |
52 ) { | 52 ) { |
53 | 53 |
54 if is_array($ip) { | 54 if is_array($ip) { |
55 $internal_ip = $ip[0] | 55 $internal_ip = $ip[0] |
56 } else { | 56 } else { |
57 $internal_ip = $ip | 57 $internal_ip = $ip |
58 } | 58 } |
59 | 59 |
60 $fqdn_name = join([$name, $base::authority], ".") | 60 $fqdn_name = join([$name, $base::zone], '.') |
61 | 61 |
62 host{$name: | 62 host{$name: |
63 ensure => present, | 63 ensure => present, |
64 ip => $internal_ip, | 64 ip => $internal_ip, |
65 name => $fqdn_name, | 65 name => $fqdn_name, |
66 host_aliases => $dns ? { | 66 host_aliases => $dns ? { |
67 undef => [], | 67 undef => [], |
68 default => $dns, | 68 default => $dns, |
69 } | 69 } |
70 } | 70 } |
71 | 71 |
72 if $ssh_public_key != undef { | 72 if $ssh_public_key != undef { |
73 | 73 |
74 $name_key = $dns ? { | 74 $name_key = $dns ? { |
75 undef => $fqdn_name, | 75 undef => $fqdn_name, |
76 default => $dns, | 76 default => $dns, |
77 } | 77 } |
78 | 78 |
79 @sshkey {$name: | 79 @sshkey {$name: |
80 name => $name_key, | 80 name => $name_key, |
81 key => $ssh_public_key, | 81 key => $ssh_public_key, |
82 type => ssh-rsa, | 82 type => ssh-rsa, |
83 host_aliases => $ip, | 83 host_aliases => $ip, |
84 } | 84 } |
85 } | 85 } |
86 | 86 |
87 } | 87 } |
88 } | 88 } |
89 | 89 |
LEFT | RIGHT |