OLD | NEW |
1 class base ($zone='adblockplus.org') { | 1 class base ($zone='adblockplus.org') { |
| 2 stage {'pre': before => Stage['main']} |
| 3 stage {'post': require => Stage['main']} |
| 4 |
| 5 class {'users': |
| 6 stage => 'pre', |
| 7 } |
| 8 |
| 9 if !defined(Class['apt']) { |
| 10 class {'apt': |
| 11 always_apt_update => true |
| 12 } |
| 13 } |
| 14 |
| 15 # Note that APT dependencies are excluded here! |
| 16 Exec['apt_update'] -> Package <|title != 'python-software-properties'|> |
| 17 |
| 18 include postfix, ssh |
| 19 |
| 20 package {['mercurial', 'vim', 'emacs', 'debian-goodies', 'htop']: |
| 21 ensure => present, |
| 22 } |
| 23 |
| 24 file {'/etc/timezone': |
| 25 ensure => file, |
| 26 owner => root, |
| 27 group => root, |
| 28 mode => 0644, |
| 29 content => 'UTC', |
| 30 notify => Service['cron'] |
| 31 } |
| 32 |
| 33 file {'/etc/localtime': |
| 34 ensure => link, |
| 35 target => '/usr/share/zoneinfo/UTC', |
| 36 notify => Service['cron'] |
| 37 } |
| 38 |
| 39 service {'cron': |
| 40 ensure => running, |
| 41 enable => true, |
| 42 } |
| 43 |
| 44 class {'logrotate': |
| 45 stage => 'post' |
| 46 } |
2 | 47 |
3 $servers = hiera('servers') | 48 $servers = hiera('servers') |
4 create_resources(base::explicit_host_record, $servers) | 49 create_resources(base::explicit_host_record, $servers) |
5 | 50 |
6 define explicit_host_record( | 51 define explicit_host_record( |
7 $ip, | 52 $ip, |
8 $ssh_public_key = undef, | 53 $ssh_public_key = undef, |
9 $role = undef, | 54 $role = undef, |
10 $dns = undef, | 55 $dns = undef, |
11 $groups = undef, | 56 $groups = undef, |
12 ) { | 57 ) { |
13 | 58 |
14 $fqdn = $dns ? { | 59 if is_array($ip) { |
15 undef => "$name.${base::zone}", | 60 $internal_ip = $ip[0] |
16 default => $dns, | 61 } else { |
| 62 $internal_ip = $ip |
17 } | 63 } |
18 | 64 |
19 $ips = is_array($ip) ? { | 65 $fqdn_name = join([$name, $base::zone], '.') |
20 true => $ip, | 66 |
21 default => [$ip], | 67 host{$name: |
| 68 ensure => present, |
| 69 ip => $internal_ip, |
| 70 name => $fqdn_name, |
| 71 host_aliases => $dns ? { |
| 72 undef => [], |
| 73 default => $dns, |
| 74 } |
22 } | 75 } |
23 | 76 |
24 $public_key = $ssh_public_key ? { | 77 if $ssh_public_key != undef { |
25 undef => undef, | 78 |
26 default => "ssh-rsa $ssh_public_key $fqdn", | 79 $name_key = $dns ? { |
| 80 undef => $fqdn_name, |
| 81 default => $dns, |
| 82 } |
| 83 |
| 84 @sshkey {$name: |
| 85 name => $name_key, |
| 86 key => $ssh_public_key, |
| 87 type => ssh-rsa, |
| 88 host_aliases => $ip, |
| 89 tag => 'base::explicit_host_record', |
| 90 } |
27 } | 91 } |
| 92 } |
28 | 93 |
29 adblockplus::host {$title: | 94 # Work around https://projects.puppetlabs.com/issues/4145 |
30 fqdn => $fqdn, | 95 Sshkey<| |> -> |
31 groups => $groups, | 96 file {'/etc/ssh/ssh_known_hosts': |
32 ips => $ips, | 97 ensure => 'present', |
33 name => $name, | 98 mode => 0644, |
34 role => $role, | 99 } |
35 public_key => $public_key, | 100 |
| 101 # Work around https://issues.adblockplus.org/ticket/3479 |
| 102 if $::environment == 'development' { |
| 103 |
| 104 file { |
| 105 '/etc/ssh/ssh_host_rsa_key': |
| 106 source => 'puppet:///modules/base/development_host_rsa_key', |
| 107 mode => 600, |
| 108 notify => Service['ssh']; |
| 109 '/etc/ssh/ssh_host_rsa_key.pub': |
| 110 source => 'puppet:///modules/base/development_host_rsa_key.pub', |
| 111 mode => 644; |
36 } | 112 } |
37 | |
38 # Implicit realization behavior has been introduced by accident in a | |
39 # previous version, hence it should be kept until class base is obsolete | |
40 # and the obsolete records have been removed | |
41 realize(Host[$title]) | |
42 realize(Sshkey[$title]) | |
43 } | 113 } |
44 } | 114 } |
OLD | NEW |