2007-12-27 12:08:19 +01:00
|
|
|
# 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
|
2007-12-27 12:08:19 +01:00
|
|
|
define user::define_user(
|
2008-10-06 22:33:54 +02:00
|
|
|
$name_comment = '',
|
|
|
|
$uid,
|
|
|
|
$gid,
|
|
|
|
$home_dir = '',
|
2008-10-04 10:53:42 +02:00
|
|
|
$home_dir_mode = '0750',
|
2008-10-06 22:33:54 +02:00
|
|
|
$ssh_key = '',
|
|
|
|
$shell = ''
|
|
|
|
){
|
|
|
|
$real_home_dir = $home_dir ? {
|
|
|
|
'' => "/home/$name",
|
|
|
|
default => $home_dir
|
|
|
|
}
|
2007-12-27 12:08:19 +01:00
|
|
|
|
2008-10-06 22:33:54 +02:00
|
|
|
$real_name_comment = $name_comment ? {
|
|
|
|
'' => $name,
|
|
|
|
default => $name_comment,
|
|
|
|
}
|
2008-01-03 18:19:00 +01:00
|
|
|
|
2008-10-06 22:33:54 +02:00
|
|
|
$real_shell = $shell ? {
|
|
|
|
'' => $operatingsystem ? {
|
|
|
|
openbsd => "/usr/local/bin/bash",
|
|
|
|
default => "/bin/bash",
|
|
|
|
},
|
|
|
|
default => $shell,
|
|
|
|
}
|
2007-12-27 12:08:19 +01:00
|
|
|
|
2008-10-06 22:33:54 +02:00
|
|
|
user { $name:
|
|
|
|
allowdupe => false,
|
|
|
|
comment => "$real_name_comment",
|
|
|
|
ensure => present,
|
|
|
|
gid => $gid,
|
|
|
|
home => $real_home_dir,
|
|
|
|
managehome => true,
|
|
|
|
shell => $real_shell,
|
|
|
|
uid => $uid,
|
|
|
|
}
|
2007-12-27 12:08:19 +01:00
|
|
|
|
2008-10-06 22:33:54 +02:00
|
|
|
case $name {
|
|
|
|
root: {}
|
|
|
|
default: {
|
|
|
|
group { $name:
|
|
|
|
allowdupe => false,
|
|
|
|
ensure => present,
|
2008-10-06 22:35:59 +02:00
|
|
|
gid => $gid,
|
2008-10-06 22:33:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-12-27 12:08:19 +01:00
|
|
|
|
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: {
|
2008-10-06 22:39:01 +02:00
|
|
|
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
|
|
|
}
|
2007-12-27 12:08:19 +01:00
|
|
|
}
|