Hacked user module to fix compatilibity with puppet 2.7
This commit is contained in:
parent
30177d3e08
commit
8d123cdb17
6 changed files with 59 additions and 55 deletions
|
@ -1,14 +1,18 @@
|
|||
|
||||
all: cron
|
||||
|
||||
cron: manifests/classes.pp manifests/virtual.pp
|
||||
cron: manifests/virtual.pp manifests/user.pp manifests/group.pp
|
||||
|
||||
manifests/virtual.pp:
|
||||
@echo "Creating virtual.pp ..."
|
||||
ruby scripts/update-virtual.rb > $@
|
||||
|
||||
manifests/classes.pp: manifests/virtual.pp
|
||||
@echo "Creating classes.pp ..."
|
||||
ruby scripts/update-classes.rb > $@
|
||||
manifests/user.pp: manifests/virtual.pp
|
||||
@echo "Creating user.pp ..."
|
||||
ruby scripts/update-classes.rb -u > $@
|
||||
|
||||
manifests/group.pp: manifests/virtual.pp
|
||||
@echo "Creating group.pp ..."
|
||||
ruby scripts/update-classes.rb -g > $@
|
||||
|
||||
.PHONY: manifests/virtual.pp
|
||||
|
|
|
@ -1,7 +1,3 @@
|
|||
|
||||
import "virtual.pp"
|
||||
import "classes.pp"
|
||||
|
||||
# Class which contains all system users that have fixed UID's
|
||||
#
|
||||
class user::system {
|
||||
|
@ -214,3 +210,41 @@ class user::system {
|
|||
|
||||
|
||||
}
|
||||
|
||||
|
||||
# Add local user account.
|
||||
#
|
||||
define user::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,
|
||||
}
|
||||
}
|
||||
|
||||
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,
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -39,6 +39,8 @@ f.readlines.each do |line|
|
|||
end
|
||||
f.close
|
||||
|
||||
user_classes = []
|
||||
group_classes = []
|
||||
|
||||
userlist = {}
|
||||
conn.search(basedn, LDAP::LDAP_SCOPE_SUBTREE, 'objectClass=posixAccount',
|
||||
|
@ -58,12 +60,12 @@ 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(User::Newuser['" + entry['uid'][0] + "'])\n"
|
||||
user_classes << "class user::user::" + entry['uid'][0] + " inherits user::virtual {\n"
|
||||
user_classes << " realize(User::Newuser['" + entry['uid'][0] + "'])\n"
|
||||
groups.each do |group|
|
||||
print " realize(Group['" + group + "'])\n"
|
||||
user_classes << " realize(Group['" + group + "'])\n"
|
||||
end
|
||||
print "}\n\n"
|
||||
user_classes << "}\n\n"
|
||||
end
|
||||
|
||||
userlist[entry.get_dn()] = entry['uid'][0]
|
||||
|
@ -89,10 +91,13 @@ conn.search(basedn, LDAP::LDAP_SCOPE_SUBTREE, 'objectClass=posixGroup',
|
|||
end
|
||||
end
|
||||
if members.length > 0
|
||||
print "class user::group::" + entry['cn'][0] + " {\n"
|
||||
group_classes << "class user::group::" + entry['cn'][0] + " {\n"
|
||||
members.uniq.sort.each do |member|
|
||||
print " include user::" + member + "\n"
|
||||
group_classes << " include user::user::" + member + "\n"
|
||||
end
|
||||
print "}\n\n"
|
||||
group_classes << "}\n\n"
|
||||
end
|
||||
}
|
||||
|
||||
puts user_classes if ARGV.include?("-u")
|
||||
puts group_classes if ARGV.include?("-g")
|
||||
|
|
|
@ -39,46 +39,7 @@ f.readlines.each do |line|
|
|||
end
|
||||
f.close
|
||||
|
||||
|
||||
print <<EOF
|
||||
define user::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,
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
print "class user::virtual {\n"
|
||||
|
||||
conn.search(basedn, LDAP::LDAP_SCOPE_SUBTREE, 'objectClass=posixAccount',
|
||||
['uid', 'uidNumber', 'gidNumber', 'gecos', 'homeDirectory',
|
||||
|
|
Loading…
Add table
Reference in a new issue