module-user/manifests/init.pp

66 lines
1.3 KiB
ObjectPascal
Raw Normal View History

# modules/user/manifests/init.pp - manage user stuff
# Copyright (C) 2007 admin@immerda.ch
#
2008-10-01 22:16:08 +02:00
# ssh:_key have to be handed over as the classname
# containing the ssh_keys
define user::define_user(
$name_comment = '',
$uid,
$gid,
$home_dir = '',
$home_dir_mode = '0750',
$ssh_key = '',
$shell = ''
){
$real_home_dir = $home_dir ? {
'' => "/home/$name",
default => $home_dir
}
$real_name_comment = $name_comment ? {
'' => $name,
default => $name_comment,
}
$real_shell = $shell ? {
'' => $operatingsystem ? {
openbsd => "/usr/local/bin/bash",
default => "/bin/bash",
},
default => $shell,
}
user { $name:
allowdupe => false,
comment => "$real_name_comment",
ensure => present,
gid => $gid,
home => $real_home_dir,
managehome => true,
shell => $real_shell,
uid => $uid,
}
case $name {
root: {}
default: {
group { $name:
allowdupe => false,
ensure => present,
2008-10-06 22:35:59 +02:00
gid => $gid,
}
}
}
2008-01-03 18:30:00 +01:00
case $ssh_key {
2008-01-03 18:32:10 +01:00
'': {}
2008-01-03 18:31:17 +01:00
default: {
User[$name]{
before => Class[$ssh_key],
}
2008-10-01 22:16:08 +02:00
include $ssh_key
2008-01-03 18:32:10 +01:00
}
2008-01-03 18:30:00 +01:00
}
}