Fixed manifest generation in user module for Puppet 2.6
This commit is contained in:
parent
bb0b107a07
commit
004854101a
2 changed files with 35 additions and 34 deletions
|
@ -59,7 +59,7 @@ conn.search(basedn, LDAP::LDAP_SCOPE_SUBTREE, 'objectClass=posixAccount',
|
||||||
# create user class
|
# create user class
|
||||||
if entry['uid'][0] !~ /.*\$.*/
|
if entry['uid'][0] !~ /.*\$.*/
|
||||||
print "class user::" + entry['uid'][0] + " inherits user::virtual {\n"
|
print "class user::" + entry['uid'][0] + " inherits user::virtual {\n"
|
||||||
print " realize(Newuser['" + entry['uid'][0] + "'])\n"
|
print " realize(User::Newuser['" + entry['uid'][0] + "'])\n"
|
||||||
groups.each do |group|
|
groups.each do |group|
|
||||||
print " realize(Group['" + group + "'])\n"
|
print " realize(Group['" + group + "'])\n"
|
||||||
end
|
end
|
||||||
|
|
|
@ -41,41 +41,42 @@ f.close
|
||||||
|
|
||||||
|
|
||||||
print <<EOF
|
print <<EOF
|
||||||
class user::virtual {
|
define user::newuser($uid, $gid, $comment, $home, $shell, $groups=undef, $requiregroups=undef) {
|
||||||
|
|
||||||
define newuser($uid, $gid, $comment, $home, $shell, $groups=undef, $requiregroups=undef) {
|
user { "${name}":
|
||||||
user { "${name}":
|
ensure => present,
|
||||||
ensure => present,
|
uid => $uid,
|
||||||
uid => $uid,
|
gid => $gid,
|
||||||
gid => $gid,
|
comment => $comment,
|
||||||
comment => $comment,
|
home => $home,
|
||||||
home => $home,
|
shell => $shell,
|
||||||
shell => $shell,
|
groups => $groups,
|
||||||
groups => $groups,
|
require => $requiregroups,
|
||||||
require => $requiregroups,
|
notify => $operatingsystem ? {
|
||||||
notify => $operatingsystem ? {
|
OpenBSD => [ Exec["user-mod-${name}"],
|
||||||
OpenBSD => [ Exec["user-mod-${name}"],
|
Exec["user-home-${name}"], ],
|
||||||
Exec["user-home-${name}"], ],
|
default => undef,
|
||||||
default => undef,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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 => "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,
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 => "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,
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class user::virtual {
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
|
||||||
|
@ -96,7 +97,7 @@ conn.search(basedn, LDAP::LDAP_SCOPE_SUBTREE, 'objectClass=posixAccount',
|
||||||
}
|
}
|
||||||
|
|
||||||
print "\n"
|
print "\n"
|
||||||
print " @newuser { '%s':\n" % entry['uid'][0]
|
print " @user::newuser { '%s':\n" % entry['uid'][0]
|
||||||
print " uid => '%s',\n" % entry['uidNumber'][0]
|
print " uid => '%s',\n" % entry['uidNumber'][0]
|
||||||
print " gid => '%s',\n" % entry['gidNumber'][0]
|
print " gid => '%s',\n" % entry['gidNumber'][0]
|
||||||
begin
|
begin
|
||||||
|
|
Loading…
Add table
Reference in a new issue