12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'manifests/authorized_key.pp', line 12
define ssh::authorized_key (
String[1] $user = $title,
Enum[present, absent] $ensure = 'present',
Optional[Ssh::Key::String] $key = undef,
Ssh::Key::Type $type = 'ssh-rsa',
Array[Ssh::Key::Option] $options = [],
) {
include ssh::params
$use_file = $ssh::params::server_class ? {
'ssh::server::chocolatey' => true,
'ssh::server::cygwin' => true,
default => false,
}
if $use_file {
if $ensure == present and $key {
if $options.length() > 0 {
$options_string = $options.join(',')
$prefix = "${options_string} "
} else {
$prefix = undef
}
$line = "${prefix}${type} ${key} ${title}"
concat::fragment { "ssh::authorized_key::file ${title} ${line}":
order => '10', # then ordered by title
target => "ssh::authorized_key::file ${user}",
content => ssh::fix_eol("${line}\n"),
}
}
} else {
# ssh_authorized_key works on this platform
ssh_authorized_key { $title:
ensure => $ensure,
key => $key,
type => $type,
user => $user,
options => $options,
}
}
}
|