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
|
all: cron
|
||||||
|
|
||||||
cron: manifests/classes.pp manifests/virtual.pp
|
cron: manifests/virtual.pp manifests/user.pp manifests/group.pp
|
||||||
|
|
||||||
manifests/virtual.pp:
|
manifests/virtual.pp:
|
||||||
@echo "Creating virtual.pp ..."
|
@echo "Creating virtual.pp ..."
|
||||||
ruby scripts/update-virtual.rb > $@
|
ruby scripts/update-virtual.rb > $@
|
||||||
|
|
||||||
manifests/classes.pp: manifests/virtual.pp
|
manifests/user.pp: manifests/virtual.pp
|
||||||
@echo "Creating classes.pp ..."
|
@echo "Creating user.pp ..."
|
||||||
ruby scripts/update-classes.rb > $@
|
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
|
.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 which contains all system users that have fixed UID's
|
||||||
#
|
#
|
||||||
class user::system {
|
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
|
end
|
||||||
f.close
|
f.close
|
||||||
|
|
||||||
|
user_classes = []
|
||||||
|
group_classes = []
|
||||||
|
|
||||||
userlist = {}
|
userlist = {}
|
||||||
conn.search(basedn, LDAP::LDAP_SCOPE_SUBTREE, 'objectClass=posixAccount',
|
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
|
# create user class
|
||||||
if entry['uid'][0] !~ /.*\$.*/
|
if entry['uid'][0] !~ /.*\$.*/
|
||||||
print "class user::" + entry['uid'][0] + " inherits user::virtual {\n"
|
user_classes << "class user::user::" + entry['uid'][0] + " inherits user::virtual {\n"
|
||||||
print " realize(User::Newuser['" + entry['uid'][0] + "'])\n"
|
user_classes << " realize(User::Newuser['" + entry['uid'][0] + "'])\n"
|
||||||
groups.each do |group|
|
groups.each do |group|
|
||||||
print " realize(Group['" + group + "'])\n"
|
user_classes << " realize(Group['" + group + "'])\n"
|
||||||
end
|
end
|
||||||
print "}\n\n"
|
user_classes << "}\n\n"
|
||||||
end
|
end
|
||||||
|
|
||||||
userlist[entry.get_dn()] = entry['uid'][0]
|
userlist[entry.get_dn()] = entry['uid'][0]
|
||||||
|
@ -89,10 +91,13 @@ conn.search(basedn, LDAP::LDAP_SCOPE_SUBTREE, 'objectClass=posixGroup',
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if members.length > 0
|
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|
|
members.uniq.sort.each do |member|
|
||||||
print " include user::" + member + "\n"
|
group_classes << " include user::user::" + member + "\n"
|
||||||
end
|
end
|
||||||
print "}\n\n"
|
group_classes << "}\n\n"
|
||||||
end
|
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
|
end
|
||||||
f.close
|
f.close
|
||||||
|
|
||||||
|
print "class user::virtual {\n"
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
conn.search(basedn, LDAP::LDAP_SCOPE_SUBTREE, 'objectClass=posixAccount',
|
conn.search(basedn, LDAP::LDAP_SCOPE_SUBTREE, 'objectClass=posixAccount',
|
||||||
['uid', 'uidNumber', 'gidNumber', 'gecos', 'homeDirectory',
|
['uid', 'uidNumber', 'gidNumber', 'gecos', 'homeDirectory',
|
||||||
|
|
Loading…
Add table
Reference in a new issue