2007-12-27 12:08:19 +01:00
|
|
|
# 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 {
|
2007-12-27 12:08:19 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
define user::define_user(
|
|
|
|
$name,
|
|
|
|
$uid,
|
|
|
|
$gid,
|
|
|
|
$home_dir = '',
|
|
|
|
$ssh_key = ''
|
|
|
|
){
|
|
|
|
|
|
|
|
$real_ssh_key = $ssh_key ? {
|
|
|
|
'' => $name,
|
|
|
|
default => $ssh_key,
|
|
|
|
}
|
|
|
|
|
|
|
|
$real_home_dir = $home_dir ? {
|
|
|
|
'' => "/home/$name",
|
|
|
|
default => $home_dir
|
|
|
|
}
|
|
|
|
|
|
|
|
$real_name_comment = $name_comment ? {
|
|
|
|
'' => $name,
|
|
|
|
default => $name_comment,
|
|
|
|
}
|
|
|
|
|
|
|
|
user { $name:
|
|
|
|
allowdupe => false,
|
2007-12-27 12:14:28 +01:00
|
|
|
comment => "$real_name_comment",
|
2007-12-27 12:08:19 +01:00
|
|
|
ensure => present,
|
|
|
|
gid => $gid,
|
|
|
|
home => $real_home_dir,
|
2008-01-02 22:58:23 +01:00
|
|
|
shell => $operatingsystem ? {
|
|
|
|
openbsd => "/usr/local/bin/bash",
|
|
|
|
default => "/bin/bash",
|
|
|
|
}
|
2007-12-27 12:08:19 +01:00
|
|
|
uid => $uid
|
|
|
|
}
|
|
|
|
|
|
|
|
group { $name:
|
|
|
|
allowdupe => false,
|
|
|
|
ensure => present,
|
|
|
|
gid => $gid
|
|
|
|
}
|
|
|
|
|
2007-12-27 12:16:08 +01:00
|
|
|
file {$real_home_dir:
|
2007-12-27 12:08:19 +01:00
|
|
|
ensure => directory,
|
|
|
|
mode => 0750, owner => $name, group => $name;
|
|
|
|
}
|
|
|
|
|
2007-12-27 12:18:53 +01:00
|
|
|
ssh::deploy_auth_key{$name: source => $real_ssh_key, user => $name, target_dir => '', group => $name}
|
2007-12-27 12:08:19 +01:00
|
|
|
}
|