module-user/manifests/init.pp

73 lines
1.2 KiB
ObjectPascal
Raw Normal View History

# modules/user/manifests/init.pp - manage user stuff
# Copyright (C) 2007 admin@immerda.ch
#
modules_dir { "user": }
2007-12-27 12:13:11 +01:00
class user {
}
define user::define_user(
$name,
2008-01-04 11:14:48 +01:00
$name_comment = '',
$uid,
$gid,
$home_dir = '',
2008-01-03 18:20:44 +01:00
$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,
2007-12-27 12:14:28 +01:00
comment => "$real_name_comment",
ensure => present,
gid => $gid,
home => $real_home_dir,
shell => $real_shell,
2008-01-02 22:59:50 +01:00
uid => $uid,
}
2008-01-04 11:05:39 +01:00
case $name {
root: {}
default: {
group { $name:
allowdupe => false,
ensure => present,
gid => $gid
}
}
}
2007-12-27 12:16:08 +01:00
file {$real_home_dir:
ensure => directory,
2008-01-04 11:08:53 +01:00
mode => 0750, owner => $name, group => $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: {
2008-01-03 19:36:18 +01:00
ssh::deploy_auth_key{"user_sshkey_${name}": source => $ssh_key, user => $name, target_dir => '', group => $name}
2008-01-03 18:32:10 +01:00
}
2008-01-03 18:30:00 +01:00
}
}