annotate modules/ssh/manifests/init.pp @ 246:c3fa3d65aa83

Update configs for Puppet 6 This *should* all be backward compatible
author IBBoard <dev@ibboard.co.uk>
date Sat, 21 Dec 2019 14:19:47 -0500
parents cd79745f0236
children d9009f54eb23
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
1 # This is an example proposed Puppet Common Module for SSH
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
2 #
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
3 # Usage Requirements:
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
4 # 1) Set $server in site.pp
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
5 # Allows for a different fileserver than the real puppetmaster
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
6 # 2) Set $os to $operatingsystem
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
7 # Saves typing, purely cosmetic
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
8 # 3) Set $osver to $operatingsystemrelease or $lsbdistrelease
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
9 # $operatingsystemrelease is not available on all platforms
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
10 #
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
11 #Taken from the the Puppet Wiki - http://projects.puppetlabs.com/projects/1/wiki/puppet_common_modules_ssh
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
12
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
13 class ssh {
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
14 # Distribution independent packages
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
15 # See also our Operating System specific sub-classes
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
16 @package { [
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
17 "openssh-clients",
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
18 "openssh-server",
21
7411baa55c01 Fix issues with newer Puppet trying to find files for abstract instances that aren't ever used
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
19 # "denyhosts"
0
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
20 ]:
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
21 ensure => installed
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
22 }
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
23
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
24 # Virtual Resources get defined before we include $operatingsystem specific
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
25 # classes, so that there is at least something to add and/or override.
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
26 #
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
27 # Additionally, this way we can realize() in sub-classes as much as we want
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
28 # to, and not concern ourselves with duplicate type definitions
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
29 #
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
30
21
7411baa55c01 Fix issues with newer Puppet trying to find files for abstract instances that aren't ever used
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
31 # @file { "/etc/denyhosts.conf":
7411baa55c01 Fix issues with newer Puppet trying to find files for abstract instances that aren't ever used
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
32 # notify => Service["denyhosts"],
7411baa55c01 Fix issues with newer Puppet trying to find files for abstract instances that aren't ever used
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
33 # require => Package["denyhosts"],
7411baa55c01 Fix issues with newer Puppet trying to find files for abstract instances that aren't ever used
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
34 # source => [
7411baa55c01 Fix issues with newer Puppet trying to find files for abstract instances that aren't ever used
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
35 # "puppet://$server/private/$domain/denyhosts/denyhosts.conf",
7411baa55c01 Fix issues with newer Puppet trying to find files for abstract instances that aren't ever used
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
36 # "puppet://$server/files/denyhosts/denyhosts.conf",
7411baa55c01 Fix issues with newer Puppet trying to find files for abstract instances that aren't ever used
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
37 # "puppet://$server/denyhosts/denyhosts.conf"
7411baa55c01 Fix issues with newer Puppet trying to find files for abstract instances that aren't ever used
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
38 # ]
7411baa55c01 Fix issues with newer Puppet trying to find files for abstract instances that aren't ever used
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
39 # }
0
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
40
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
41 @file { "/etc/ssh/ssh_config":
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
42 owner => "root",
246
c3fa3d65aa83 Update configs for Puppet 6
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
43 mode => '0644',
0
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
44 require => Package["openssh-clients"],
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
45 source => [
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
46 #
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
47 # See rationale for an explanation on this list of sources
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
48 # http://reductivelabs.com/trac/puppet/wiki/PuppetCommonModules/SSH
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
49 #
21
7411baa55c01 Fix issues with newer Puppet trying to find files for abstract instances that aren't ever used
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
50 "puppet://$server/private/$domain/ssh/$operatingsystem/$osver/ssh_config.$hostname",
7411baa55c01 Fix issues with newer Puppet trying to find files for abstract instances that aren't ever used
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
51 "puppet://$server/private/$domain/ssh/$operatingsystem/$osver/ssh_config",
7411baa55c01 Fix issues with newer Puppet trying to find files for abstract instances that aren't ever used
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
52 "puppet://$server/private/$domain/ssh/$operatingsystem/ssh_config.$hostname",
7411baa55c01 Fix issues with newer Puppet trying to find files for abstract instances that aren't ever used
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
53 "puppet://$server/private/$domain/ssh/$operatingsystem/ssh_config",
0
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
54 "puppet://$server/private/$domain/ssh/ssh_config.$hostname",
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
55 "puppet://$server/private/$domain/ssh/ssh_config",
21
7411baa55c01 Fix issues with newer Puppet trying to find files for abstract instances that aren't ever used
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
56 "puppet://$server/files/ssh/$operatingsystem/$osver/ssh_config.$hostname",
7411baa55c01 Fix issues with newer Puppet trying to find files for abstract instances that aren't ever used
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
57 "puppet://$server/files/ssh/$operatingsystem/$osver/ssh_config",
7411baa55c01 Fix issues with newer Puppet trying to find files for abstract instances that aren't ever used
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
58 "puppet://$server/files/ssh/$operatingsystem/ssh_config.$hostname",
7411baa55c01 Fix issues with newer Puppet trying to find files for abstract instances that aren't ever used
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
59 "puppet://$server/files/ssh/$operatingsystem/ssh_config",
0
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
60 "puppet://$server/files/ssh/ssh_config.$hostname",
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
61 "puppet://$server/files/ssh/ssh_config",
21
7411baa55c01 Fix issues with newer Puppet trying to find files for abstract instances that aren't ever used
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
62 "puppet://$server/ssh/$operatingsystem/$osver/ssh_config",
7411baa55c01 Fix issues with newer Puppet trying to find files for abstract instances that aren't ever used
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
63 "puppet://$server/ssh/$operatingsystem/ssh_config",
0
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
64 "puppet://$server/ssh/ssh_config"
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
65 ],
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
66 sourceselect => first
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
67 }
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
68
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
69 @file { "/etc/ssh/sshd_config":
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
70 owner => "root",
246
c3fa3d65aa83 Update configs for Puppet 6
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
71 mode => '0644',
0
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
72 notify => Service["openssh-server"],
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
73 require => Package["openssh-server"],
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
74 source => [
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
75 #
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
76 # See rationale for an explanation on this list of sources
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
77 # http://reductivelabs.com/trac/puppet/wiki/PuppetCommonModules/SSH
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
78 #
21
7411baa55c01 Fix issues with newer Puppet trying to find files for abstract instances that aren't ever used
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
79 "puppet://$server/private/$domain/ssh/$operatingsystem/$osver/sshd_config.$hostname",
7411baa55c01 Fix issues with newer Puppet trying to find files for abstract instances that aren't ever used
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
80 "puppet://$server/private/$domain/ssh/$operatingsystem/$osver/sshd_config",
7411baa55c01 Fix issues with newer Puppet trying to find files for abstract instances that aren't ever used
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
81 "puppet://$server/private/$domain/ssh/$operatingsystem/sshd_config.$hostname",
7411baa55c01 Fix issues with newer Puppet trying to find files for abstract instances that aren't ever used
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
82 "puppet://$server/private/$domain/ssh/$operatingsystem/sshd_config",
0
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
83 "puppet://$server/private/$domain/ssh/sshd_config.$hostname",
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
84 "puppet://$server/private/$domain/ssh/sshd_config",
21
7411baa55c01 Fix issues with newer Puppet trying to find files for abstract instances that aren't ever used
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
85 "puppet://$server/files/ssh/$operatingsystem/$osver/sshd_config.$hostname",
7411baa55c01 Fix issues with newer Puppet trying to find files for abstract instances that aren't ever used
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
86 "puppet://$server/files/ssh/$operatingsystem/$osver/sshd_config",
7411baa55c01 Fix issues with newer Puppet trying to find files for abstract instances that aren't ever used
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
87 "puppet://$server/files/ssh/$operatingsystem/sshd_config.$hostname",
7411baa55c01 Fix issues with newer Puppet trying to find files for abstract instances that aren't ever used
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
88 "puppet://$server/files/ssh/$operatingsystem/sshd_config",
0
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
89 "puppet://$server/files/ssh/sshd_config.$hostname",
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
90 "puppet://$server/files/ssh/sshd_config",
21
7411baa55c01 Fix issues with newer Puppet trying to find files for abstract instances that aren't ever used
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
91 "puppet://$server/ssh/$operatingsystem/$osver/sshd_config",
7411baa55c01 Fix issues with newer Puppet trying to find files for abstract instances that aren't ever used
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
92 "puppet://$server/ssh/$operatingsystem/sshd_config",
0
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
93 "puppet://$server/ssh/sshd_config"
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
94 ],
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
95 sourceselect => first
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
96 }
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
97
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
98 @service { "openssh-server":
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
99 enable => true,
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
100 ensure => running,
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
101 require => [
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
102 File["/etc/ssh/sshd_config"],
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
103
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
104 Package["openssh-server"]
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
105 ]
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
106 }
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
107
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
108
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
109 # Include operatingsystem specific subclass
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
110 case $::osfamily {
246
c3fa3d65aa83 Update configs for Puppet 6
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
111 'Redhat': {
0
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
112 include ssh::centos
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
113 }
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
114 default:{fail("Invalid OS type for SSH - $osfamily")}
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
115 }
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
116 }
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
117
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
118 class ssh::client inherits ssh {
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
119 realize(Package["openssh-clients"])
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
120 }
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
121
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
122 class ssh::server inherits ssh {
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
123 realize(File["/etc/ssh/sshd_config"])
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
124 realize(Package["openssh-server"])
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
125 realize(Service["openssh-server"])
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
126 }
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
127
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
128 class ssh::centos inherits ssh {
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
129 File["/etc/ssh/ssh_config"] {
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
130 group => "root"
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
131 }
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
132
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
133 Service["openssh-server"] {
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
134 name => "sshd",
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
135 hasrestart => true,
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
136 hasstatus => true,
46
cd79745f0236 Don't specify how to restart SSHD so that Puppet does its default thing (and works)
IBBoard <dev@ibboard.co.uk>
parents: 21
diff changeset
137 # restart => "/etc/init.d/sshd restart",
cd79745f0236 Don't specify how to restart SSHD so that Puppet does its default thing (and works)
IBBoard <dev@ibboard.co.uk>
parents: 21
diff changeset
138 # status => "/etc/init.d/sshd status"
0
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
139 }
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
140 }