used the new language constructs to make it a lot more readable

This commit is contained in:
mh 2009-03-12 23:25:54 +00:00
parent 04c2da144f
commit 8c4350ecab

View file

@ -69,16 +69,14 @@ define user::managed(
if $managehome {
case $ensure {
absent: {
if $ensure == 'absent' {
file{"$real_homedir":
ensure => absent,
purge => true,
force => true,
recurese => true,
}
}
default: {
} else {
file{"$real_homedir":
ensure => directory,
require => User[$name],
@ -98,47 +96,38 @@ define user::managed(
}
}
}
}
case $uid {
'absent': { info("Not defining a uid for user $name") }
default: {
if $uid != 'absent' {
User[$name]{
uid => $uid,
}
}
}
case $gid {
'absent': { info("Not defining a gid for user $name") }
default: {
case $gid {
'uid': {
case $uid {
'absent': { info("Not defining a gid for user $name as uid is absent") }
default: {
if $gid != 'absent' {
if $gid != 'uid' {
if $uid != 'absent' {
$real_gid = $uid
}
}
}
default: {
} else {
$real_gid = $gid
}
}
if $real_gid {
User[$name]{
gid => $real_gid,
}
}
}
}
case $name {
root: {}
default: {
case $uid {
'absent': { info("can not manage group for $name as no uid is supplied") }
default: {
if $name != 'root' {
if $uid == 'absent' {
if $manage_group {
if $ensure == 'absent' {
group{$name:
ensure => absent,
}
}
}
} else {
if $manage_group {
group { $name:
allowdupe => false,
@ -152,24 +141,17 @@ define user::managed(
}
}
}
}
}
case $ensure {
present: {
case $sshkey {
'absent': { info("no sshkey to manage for user $name") }
default: {
if $sshkey != 'absent' {
User[$name]{
before => Class[$sshkey],
}
include $sshkey
}
}
case $password {
'absent': { info("not managing the password for user $name") }
default: {
if $password != 'absent' {
case $operatingsystem {
openbsd: {
exec { "setpass ${name}":
@ -183,11 +165,10 @@ define user::managed(
if $password_crypted {
$real_password = $password
} else {
case $password_salt {
'': { fail("To use unencrypted passwords you have to define a variable \$password_salt to an 8 character salt for passwords!") }
default: {
if $password_salt {
$real_password = mkpasswd($password,$password_salt)
}
} else {
fail("To use unencrypted passwords you have to define a variable \$password_salt to an 8 character salt for passwords!")
}
}
User[$name]{
@ -200,7 +181,6 @@ define user::managed(
}
}
}
}
# gid: by default it will take the same as the uid
define user::sftp_only(