user: LDAP user management refactoring
This commit is contained in:
parent
d784356112
commit
0b73e7782c
3 changed files with 144 additions and 162 deletions
|
@ -355,37 +355,26 @@ class user::system {
|
|||
|
||||
# Add local user account.
|
||||
#
|
||||
define user::newuser($uid, $gid, $comment, $home, $shell, $groups=undef, $requiregroups=undef) {
|
||||
define user::add($uid, $gid, $comment, $home, $shell, $groups=undef) {
|
||||
|
||||
user { $name:
|
||||
ensure => present,
|
||||
uid => $uid,
|
||||
gid => $gid,
|
||||
comment => $comment,
|
||||
home => $home,
|
||||
shell => $shell,
|
||||
groups => $groups,
|
||||
require => $requiregroups,
|
||||
notify => $::operatingsystem ? {
|
||||
OpenBSD => [ Exec["user-mod-${name}"],
|
||||
Exec["user-home-${name}"], ],
|
||||
default => undef,
|
||||
ensure => present,
|
||||
managehome => true,
|
||||
uid => $uid,
|
||||
gid => $gid,
|
||||
comment => $comment,
|
||||
home => $home,
|
||||
shell => $shell,
|
||||
groups => $groups,
|
||||
}
|
||||
|
||||
if $::operatingsystem == "OpenBSD" {
|
||||
exec { "usermod -L ldap ${name}":
|
||||
refreshonly => true,
|
||||
path => "/sbin:/usr/sbin:/bin:/usr/bin",
|
||||
subscribe => User[$name],
|
||||
require => File["/etc/login.conf"],
|
||||
}
|
||||
}
|
||||
|
||||
exec { "user-mod-${name}":
|
||||
command => "usermod -L ldap ${name}",
|
||||
path => "/sbin:/usr/sbin:/bin:/usr/bin",
|
||||
refreshonly => true,
|
||||
require => File["/etc/login.conf"],
|
||||
}
|
||||
|
||||
exec { "user-home-${name}":
|
||||
command => "/bin/sh -c 'umask 077; mkdir -p ${home} && tar cf - . | tar xf - -C ${home} && chown -R ${uid}:${gid} ${home}'",
|
||||
cwd => "/etc/skel",
|
||||
path => "/sbin:/usr/sbin:/bin:/usr/bin",
|
||||
creates => $home,
|
||||
refreshonly => true,
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue