merged with puzzle
This commit is contained in:
parent
82686eb0de
commit
40d5be01b1
1 changed files with 79 additions and 29 deletions
|
@ -1,35 +1,46 @@
|
|||
# modules/user/manifests/init.pp - manage user stuff
|
||||
# Copyright (C) 2007 admin@immerda.ch
|
||||
#
|
||||
# user module
|
||||
#
|
||||
# Copyright (C) 2007 admin@immerda.ch
|
||||
# Copyright 2008, Puzzle ITC
|
||||
# Marcel Härry haerry+puppet(at)puzzle.ch
|
||||
# Simon Josi josi+puppet(at)puzzle.ch
|
||||
#
|
||||
# This program is free software; you can redistribute
|
||||
# it and/or modify it under the terms of the GNU
|
||||
# General Public License version 3 as published by
|
||||
# the Free Software Foundation.
|
||||
|
||||
# ssh:_key have to be handed over as the classname
|
||||
# containing the ssh_keys
|
||||
define user::define_user(
|
||||
$name_comment = '',
|
||||
$uid,
|
||||
$gid,
|
||||
$name_comment = 'absent',
|
||||
$uid = 'absent',
|
||||
$gid = 'absent',
|
||||
$groups = [],
|
||||
$membership = 'minimum',
|
||||
$home_dir = '',
|
||||
$home_dir_mode = '0750',
|
||||
$ssh_key = '',
|
||||
$shell = ''
|
||||
$homedir = 'absent',
|
||||
$managehome = 'true',
|
||||
$homedir_mode = '0750',
|
||||
$sshkey = 'absent',
|
||||
$shell = 'absent'
|
||||
){
|
||||
$real_home_dir = $home_dir ? {
|
||||
'' => "/home/$name",
|
||||
default => $home_dir
|
||||
|
||||
$real_homedir = $homedir ? {
|
||||
'absent' => "/home/$name",
|
||||
default => $homedir
|
||||
}
|
||||
|
||||
$real_name_comment = $name_comment ? {
|
||||
'' => $name,
|
||||
default => $name_comment,
|
||||
'absent' => $name,
|
||||
default => $name_comment,
|
||||
}
|
||||
|
||||
$real_shell = $shell ? {
|
||||
'' => $operatingsystem ? {
|
||||
openbsd => "/usr/local/bin/bash",
|
||||
default => "/bin/bash",
|
||||
},
|
||||
'absent' => $operatingsystem ? {
|
||||
openbsd => "/usr/local/bin/bash",
|
||||
default => "/bin/bash",
|
||||
},
|
||||
default => $shell,
|
||||
}
|
||||
|
||||
|
@ -37,22 +48,61 @@ define user::define_user(
|
|||
allowdupe => false,
|
||||
comment => "$real_name_comment",
|
||||
ensure => present,
|
||||
gid => $gid,
|
||||
home => $real_home_dir,
|
||||
managehome => true,
|
||||
home => $real_homedir,
|
||||
managehome => $managehome,
|
||||
shell => $real_shell,
|
||||
uid => $uid,
|
||||
groups => $groups,
|
||||
membership => $membership,
|
||||
}
|
||||
|
||||
case $name {
|
||||
root: {}
|
||||
default: {
|
||||
group { $name:
|
||||
allowdupe => false,
|
||||
ensure => present,
|
||||
gid => $gid,
|
||||
file{"$real_homedir":
|
||||
ensure => directory,
|
||||
require => User[$name],
|
||||
owner => $name, group => $name, mode => $homedir_mode;
|
||||
}
|
||||
|
||||
case $uid {
|
||||
'absent': { info("Not defining a uid for user $name") }
|
||||
default: {
|
||||
User[$name]{
|
||||
uid => $uid,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
case $gid {
|
||||
'absent': { info("Not defining a gid for user $name") }
|
||||
default: {
|
||||
User[$name]{
|
||||
gid => $gid,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
case $name {
|
||||
root: {}
|
||||
default: {
|
||||
group { $name:
|
||||
allowdupe => false,
|
||||
ensure => present,
|
||||
require => User[$name],
|
||||
}
|
||||
case $gid {
|
||||
'absent': { info("not defining a gid for group $name") }
|
||||
default: {
|
||||
Group[$name]{
|
||||
gid => $gid,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
case $gid {
|
||||
'absent': { info("no gid defined for user $name") }
|
||||
default: {
|
||||
File[$real_homedir]{
|
||||
group => $gid,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue