module-sshd/manifests/ssh_authorized_key.pp

49 lines
1 KiB
ObjectPascal
Raw Normal View History

2009-09-29 19:53:04 +02:00
# wrapper to have some defaults.
define sshd::ssh_authorized_key(
$ensure = 'present',
2009-09-29 19:53:04 +02:00
$type = 'ssh-dss',
2009-12-18 19:06:43 +01:00
$key = 'absent',
$user = '',
$target = undef,
2009-09-29 19:53:04 +02:00
$options = 'absent'
){
2009-12-18 19:06:43 +01:00
if ($ensure=='present') and ($key=='absent') {
fail("You have to set \$key for Sshd::Ssh_authorized_key[${name}]!")
}
$real_user = $user ? {
2013-02-03 00:30:54 +01:00
false => $name,
'' => $name,
default => $user,
}
case $target {
2009-12-10 23:34:57 +01:00
undef,'': {
case $real_user {
'root': { $real_target = '/root/.ssh/authorized_keys' }
default: { $real_target = "/home/${real_user}/.ssh/authorized_keys" }
}
2009-09-29 19:53:04 +02:00
}
default: {
$real_target = $target
2009-09-29 19:53:04 +02:00
}
}
ssh_authorized_key{$name:
ensure => $ensure,
2013-02-03 00:30:54 +01:00
type => $type,
key => $key,
user => $real_user,
target => $real_target,
}
2009-09-29 19:53:04 +02:00
case $options {
2013-02-03 00:30:54 +01:00
'absent': { info("not setting any option for ssh_authorized_key: ${name}") }
default: {
Ssh_authorized_key[$name]{
options => $options,
}
2009-09-29 19:53:04 +02:00
}
}
2009-09-29 19:53:04 +02:00
}