Fixed manifest generation in user module for Puppet 2.6

This commit is contained in:
Ossi Salmi 2011-08-19 11:03:04 +03:00 committed by Timo Mkinen
parent bb0b107a07
commit 004854101a
2 changed files with 35 additions and 34 deletions

View file

@ -59,7 +59,7 @@ conn.search(basedn, LDAP::LDAP_SCOPE_SUBTREE, 'objectClass=posixAccount',
# create user class
if entry['uid'][0] !~ /.*\$.*/
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|
print " realize(Group['" + group + "'])\n"
end

View file

@ -41,41 +41,42 @@ f.close
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}":
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,
}
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,
}
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
@ -96,7 +97,7 @@ conn.search(basedn, LDAP::LDAP_SCOPE_SUBTREE, 'objectClass=posixAccount',
}
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 " gid => '%s',\n" % entry['gidNumber'][0]
begin