]> git.immae.eu Git - perso/Immae/Projets/Puppet.git/blame - modules/base_installation/manifests/users.pp
Order ldap configuration by priority
[perso/Immae/Projets/Puppet.git] / modules / base_installation / manifests / users.pp
CommitLineData
7fed35a4
IB
1class base_installation::users (
2 $users = $base_installation::system_users,
3) inherits base_installation {
4 ensure_packages('ruby-shadow')
5 user { 'root':
b193066f
IB
6 password => '!',
7 purge_ssh_keys => ["/root/.ssh/authorized_keys"],
7fed35a4
IB
8 }
9
10 class { 'sudo':
11 config_file_replace => false,
12 # Missing in the sudo package, should no be mandatory
13 package_ldap => false
14 }
15
16 sudo::conf { 'wheel':
17 priority => 10,
18 content => "%wheel ALL=(ALL) ALL"
19 }
20
21 contain "sudo"
22
23 $users.each |$user| {
d13887c5
IB
24 if ($user["username"] != "root") {
25 user { "${user[username]}:${user[userid]}":
26 name => $user[username],
27 uid => $user[userid],
28 ensure => "present",
29 groups => $user[groups],
30 managehome => true,
31 system => !!$user[system],
32 home => "/home/${user[username]}",
33 notify => Exec["remove_password:${user[username]}:${user[userid]}"],
34 purge_ssh_keys => true
35 }
7fed35a4 36
d13887c5
IB
37 exec { "remove_password:${user[username]}:${user[userid]}":
38 command => "/usr/bin/chage -d 0 ${user[username]} && /usr/bin/passwd -d ${user[username]}",
39 onlyif => "/usr/bin/test -z '${user[password]}'",
40 refreshonly => true
41 }
7fed35a4
IB
42 }
43
0a21fb6c
IB
44 if has_key($user, "keys") {
45 $user[keys].each |$key| {
d13887c5
IB
46 if has_key($key, "command") {
47 ssh_authorized_key { "${user[username]}@${key[host]}":
48 name => "${user[username]}@${key[host]}",
49 user => $user[username],
50 type => $key[key_type],
51 key => $key[key],
b193066f 52 options => [
d13887c5 53 "command=\"${key[command]}\"",
b193066f
IB
54 "no-port-forwarding",
55 "no-X11-forwarding",
56 "no-pty",
57 ],
d13887c5
IB
58 }
59 } else {
60 ssh_authorized_key { "${user[username]}@${key[host]}":
61 name => "${user[username]}@${key[host]}",
62 user => $user[username],
63 type => $key[key_type],
64 key => $key[key],
b193066f
IB
65 }
66 }
7fed35a4
IB
67 }
68 }
69 }
70
71}