aboutsummaryrefslogtreecommitdiff
path: root/manifests/ssh_authorized_key.pp
diff options
context:
space:
mode:
Diffstat (limited to 'manifests/ssh_authorized_key.pp')
-rw-r--r--manifests/ssh_authorized_key.pp52
1 files changed, 29 insertions, 23 deletions
diff --git a/manifests/ssh_authorized_key.pp b/manifests/ssh_authorized_key.pp
index 2d528da..9374e15 100644
--- a/manifests/ssh_authorized_key.pp
+++ b/manifests/ssh_authorized_key.pp
@@ -3,34 +3,40 @@ define sshd::ssh_authorized_key(
$type = 'ssh-dss',
$key,
$user = 'root',
- $target = 'absent',
+ $target = undef,
$options = 'absent'
){
- case $target {
- 'absent': {
- case $user {
- 'root': { $real_target = '/root/.ssh/authorized_keys' }
- default: { $real_target = "/home/${user}/.ssh/authorized_keys" }
- }
- }
- default: {
- $real_target = $target
- }
+ $real_user = $user ? {
+ false => $name,
+ "" => $name,
+ default => $user,
+ }
+
+ case $target {
+ undef: {
+ case $user {
+ 'root': { $real_target = '/root/.ssh/authorized_keys' }
+ default: { $real_target = "/home/${user}/.ssh/authorized_keys" }
+ }
}
- ssh_authorized_key{$name:
- type => $type,
- key => $key,
- user => $user,
- target => $real_target,
+ default: {
+ $real_target = $target
}
+ }
+ ssh_authorized_key{$name:
+ type => $type,
+ key => $key,
+ user => $real_user,
+ target => $real_target,
+ }
- case $options {
- 'absent': { info("not setting any option for ssh_authorized_key: $name") }
- default: {
- Ssh_authorized_key[$name]{
- options => $options,
- }
- }
+ case $options {
+ 'absent': { info("not setting any option for ssh_authorized_key: $name") }
+ default: {
+ Ssh_authorized_key[$name]{
+ options => $options,
+ }
}
+ }
}