Skip to content

Commit 5169994

Browse files
committed
Update ssh to 3216cd87ae97ee74f06edd0e4868cedbc90e86d9
3216cd87ae97ee74f06edd0e4868cedbc90e86d9 add summary, new release v2.8.1 10d5e39904498e64422450801779392085ca7baf new release v2.8.0 e7670e1640ed8569fce2461bcc1e804eb101383f Merge branch 'ccin2p3-feature/per_user_config' b296ee7d6f6ce2d4dc5fd3939c13364b6eddaaa1 fix users_client_options if no hiera values found e7a0ba390bbb3eb5a6f754ca513230a2f8dfaf53 Merge branch 'feature/per_user_config' of https://github.com/ccin2p3/puppet-ssh into ccin2p3-feature/per_user_config 0020bd68c6257db48092e131b233b1bf417bc3ba new release v2.7.0 adcce9563ad83d52b5979b08db696aa4af5488a0 cast port value to string before striping, fixes redhat-openstack#112 da7c691f0931dc61ca368d51445ffaddc6b2aba3 ignore Gemfile.lock and vendor dir d1f515e6065a811286e9ebfce2afe07843858e3d Merge pull request redhat-openstack#122 from stjeanp/master 28d63dbde9c4d214d826ecb6f4644df820e3e6f8 Merge pull request redhat-openstack#115 from cisco87/patch-1 d316ce453117849eb10833e8c9d6a84284b14912 Merge pull request redhat-openstack#114 from tedivm/concat_bug 828e7cf6d032d573b63bac47e272aecae348446d Merge pull request redhat-openstack#113 from tedivm/client_server_bug 5526b90bcbb1862acf86677ad214f98c7bd62d4f Fixes to make puppet-lint happy 10192afbc62ef8de13ff0522daf6531f9ff91e01 New type for managing users ssh configuration file 34e3e6977c5661ea269ccd5b80b74a9f097c576b Fixed parameter alignment cb626fd50fd039f51ffa4912182ad139f7203a93 It's needed since due for a bug in puppet hiera_hash might return an empty string instead of the default value. 6629299da7d788384a71ce30e5c57ac90c668a49 Deleted superfluous relationship 3e5821025f819822fd3df0b1f25c1589500959d0 Corrected dependency direction ced449b51874d5d408c1ff59faddc42c3eedcbfb Made config class compatible with new concat module fc6aa145e42fdaf801f22e422e43f40e8e151fb0 Corrected bug which applied server settings to the client Change-Id: I6d7aa52b30763880ebe8dc20a3962081befede15
1 parent c29e7e8 commit 5169994

14 files changed

Lines changed: 333 additions & 15 deletions

File tree

Puppetfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ mod 'snmp',
179179
:git => 'https://github.com/razorsedge/puppet-snmp.git'
180180

181181
mod 'ssh',
182-
:commit => '5afa7d6cc30c129af66612928f3ab51f89ad7a26',
182+
:commit => '3216cd87ae97ee74f06edd0e4868cedbc90e86d9',
183183
:git => 'https://github.com/saz/puppet-ssh.git'
184184

185185
mod 'staging',

ssh/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
pkg/
22
*.swp
33
.DS_Store
4+
Gemfile.lock
5+
vendor/

ssh/README.markdown

Lines changed: 74 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ port 22 and 2222) should be passed as an array.
2727

2828
This is working for both, client and server.
2929

30-
### Both client and server
30+
### Both client, server and per user client configuration
3131
Host keys will be collected and distributed unless
3232
`storeconfigs_enabled` is `false`.
3333

@@ -55,6 +55,15 @@ or
5555
'User' => 'ec2-user',
5656
},
5757
},
58+
users_client_options => {
59+
'bob' => {
60+
options => {
61+
'Host *.alice.fr' => {
62+
'User' => 'alice',
63+
},
64+
},
65+
},
66+
},
5867
}
5968
```
6069

@@ -77,6 +86,13 @@ ssh::client_options:
7786
SendEnv: 'LANG LC_*'
7887
ForwardX11Trusted: 'yes'
7988
ServerAliveInterval: '10'
89+
90+
ssh::users_client_options:
91+
'bob':
92+
'options':
93+
'Host *.alice.fr':
94+
'User': 'alice'
95+
'PasswordAuthentication': 'no'
8096
```
8197

8298
### Client only
@@ -105,6 +121,63 @@ or
105121
}
106122
```
107123

124+
### Per user client configuration
125+
126+
**User's home is expected to be /home/bob**
127+
128+
SSH configuration file will be `/home/bob/.ssh/config`.
129+
130+
```puppet
131+
::ssh::client::config::user { 'bob':
132+
ensure => present,
133+
options => {
134+
'HashKnownHosts' => 'yes'
135+
}
136+
}
137+
```
138+
139+
**User's home is passed to define type**
140+
141+
SSH configuration file will be `/var/lib/bob/.ssh/config` and puppet will
142+
manage directory `/var/lib/bob/.ssh`.
143+
144+
```puppet
145+
::ssh::client::config::user { 'bob':
146+
ensure => present,
147+
user_home_dir => '/var/lib/bob',
148+
options => {
149+
'HashKnownHosts' => 'yes'
150+
}
151+
}
152+
```
153+
154+
**User's ssh directory should not be managed by the define type**
155+
156+
SSH configuration file will be `/var/lib/bob/.ssh/config`.
157+
158+
```puppet
159+
::ssh::client::config::user { 'bob':
160+
ensure => present,
161+
user_home_dir => '/var/lib/bob',
162+
manage_user_ssh_dir => false,
163+
options => {
164+
'HashKnownHosts' => 'yes'
165+
}
166+
}
167+
```
168+
169+
**User's ssh config is specified with an absolute path**
170+
171+
```puppet
172+
::ssh::client::config::user { 'bob':
173+
ensure => present,
174+
target => '/var/lib/bob/.ssh/ssh_config',
175+
options => {
176+
'HashKnownHosts' => 'yes'
177+
}
178+
}
179+
```
180+
108181
### Server only
109182
Host keys will be collected for client distribution unless
110183
`storeconfigs_enabled` is `false`

ssh/manifests/client/config.pp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
class ssh::client::config {
1+
class ssh::client::config
2+
{
3+
$options = $::ssh::client::merged_options
4+
25
file { $ssh::params::ssh_config:
36
ensure => present,
47
owner => '0',
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#
2+
# Copyright (c) IN2P3 Computing Centre, IN2P3, CNRS
3+
# Contributor: Remi Ferrand <remi{dot}ferrand_at_cc(dot)in2p3.fr> (2015)
4+
#
5+
define ssh::client::config::user(
6+
$ensure = present,
7+
$target = undef,
8+
$user_home_dir = undef,
9+
$manage_user_ssh_dir = true,
10+
$options = {}
11+
)
12+
{
13+
validate_re($ensure, '^(present|absent)$')
14+
validate_hash($options)
15+
validate_bool($manage_user_ssh_dir)
16+
17+
include ::ssh::params
18+
19+
$_files_ensure = $ensure ? { 'present' => 'file', 'absent' => 'absent' }
20+
21+
# If a specific target file was specified,
22+
# it must have higher priority than any
23+
# other parameter.
24+
if ($target != undef) {
25+
validate_absolute_path($target)
26+
$_target = $target
27+
}
28+
else {
29+
if ($user_home_dir == undef) {
30+
$_user_home_dir = "/home/${name}"
31+
}
32+
else {
33+
validate_absolute_path($user_home_dir)
34+
$_user_home_dir = $user_home_dir
35+
}
36+
37+
$user_ssh_dir = "${_user_home_dir}/.ssh"
38+
$_target = "${user_ssh_dir}/config"
39+
40+
if ($manage_user_ssh_dir == true) {
41+
file { $user_ssh_dir:
42+
ensure => directory,
43+
owner => $name,
44+
mode => $::ssh::params::user_ssh_directory_default_mode,
45+
before => File[$_target]
46+
}
47+
}
48+
}
49+
50+
file { $_target:
51+
ensure => $_files_ensure,
52+
owner => $name,
53+
mode => $::ssh::params::user_ssh_config_default_mode,
54+
content => template("${module_name}/ssh_config.erb")
55+
}
56+
}

ssh/manifests/init.pp

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,47 @@
11
class ssh (
22
$server_options = {},
33
$client_options = {},
4+
$users_client_options = {},
45
$version = 'present',
56
$storeconfigs_enabled = true
67
) inherits ssh::params {
78

9+
validate_hash($server_options)
10+
validate_hash($client_options)
11+
validate_hash($users_client_options)
12+
validate_bool($storeconfigs_enabled)
13+
814
# Merge hashes from multiple layer of hierarchy in hiera
915
$hiera_server_options = hiera_hash("${module_name}::server_options", undef)
1016
$hiera_client_options = hiera_hash("${module_name}::client_options", undef)
17+
$hiera_users_client_options = hiera_hash("${module_name}::users_client_options", undef)
1118

1219
$fin_server_options = $hiera_server_options ? {
1320
undef => $server_options,
1421
default => $hiera_server_options,
1522
}
1623

1724
$fin_client_options = $hiera_client_options ? {
18-
undef => $server_options,
25+
undef => $client_options,
1926
default => $hiera_client_options,
2027
}
2128

29+
$fin_users_client_options = $hiera_users_client_options ? {
30+
undef => $users_client_options,
31+
default => $hiera_users_client_options,
32+
}
33+
2234
class { 'ssh::server':
35+
ensure => $version,
2336
storeconfigs_enabled => $storeconfigs_enabled,
2437
options => $fin_server_options,
25-
ensure => $version,
2638
}
2739

2840
class { 'ssh::client':
41+
ensure => $version,
2942
storeconfigs_enabled => $storeconfigs_enabled,
3043
options => $fin_client_options,
31-
ensure => $version,
3244
}
45+
46+
create_resources('::ssh::client::config::user', $fin_users_client_options)
3347
}

ssh/manifests/params.pp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,4 +131,7 @@
131131
'HashKnownHosts' => 'yes',
132132
},
133133
}
134+
135+
$user_ssh_directory_default_mode = '0700'
136+
$user_ssh_config_default_mode = '0600'
134137
}

ssh/manifests/server.pp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
$fin_options = $hiera_options ? {
1111
undef => $options,
12+
'' => $options,
1213
default => $hiera_options,
1314
}
1415

@@ -18,8 +19,6 @@
1819
include ssh::server::config
1920
include ssh::server::service
2021

21-
File[$ssh::params::sshd_config] ~> Service[$ssh::params::service_name]
22-
2322
anchor { 'ssh::server::start': }
2423
anchor { 'ssh::server::end': }
2524

ssh/manifests/server/config.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
class ssh::server::config {
2-
File[$ssh::params::sshd_config] ~> Service[$ssh::params::service_name]
32

43
concat { $ssh::params::sshd_config:
54
ensure => present,
65
owner => '0',
76
group => '0',
87
mode => '0600',
8+
notify => Service[$ssh::params::service_name]
99
}
1010

1111
concat::fragment { 'global config':

ssh/manifests/server/match_block.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
define ssh::server::match_block ($type = 'user', $order = 50, $options,) {
1+
define ssh::server::match_block ($options, $type = 'user', $order = 50,) {
22
concat::fragment { "match_block ${name}":
33
target => $ssh::params::sshd_config,
44
content => template("${module_name}/sshd_match_block.erb"),

0 commit comments

Comments
 (0)