diff options
-rw-r--r-- | modules/base_installation/manifests/users.pp | 60 |
1 files changed, 39 insertions, 21 deletions
diff --git a/modules/base_installation/manifests/users.pp b/modules/base_installation/manifests/users.pp index f893c51..34df4bd 100644 --- a/modules/base_installation/manifests/users.pp +++ b/modules/base_installation/manifests/users.pp | |||
@@ -3,7 +3,8 @@ class base_installation::users ( | |||
3 | ) inherits base_installation { | 3 | ) inherits base_installation { |
4 | ensure_packages('ruby-shadow') | 4 | ensure_packages('ruby-shadow') |
5 | user { 'root': | 5 | user { 'root': |
6 | password => '!' | 6 | password => '!', |
7 | purge_ssh_keys => ["/root/.ssh/authorized_keys"], | ||
7 | } | 8 | } |
8 | 9 | ||
9 | class { 'sudo': | 10 | class { 'sudo': |
@@ -20,31 +21,48 @@ class base_installation::users ( | |||
20 | contain "sudo" | 21 | contain "sudo" |
21 | 22 | ||
22 | $users.each |$user| { | 23 | $users.each |$user| { |
23 | user { "${user[username]}:${user[userid]}": | 24 | if ($user["username"] != "root") { |
24 | name => $user[username], | 25 | user { "${user[username]}:${user[userid]}": |
25 | uid => $user[userid], | 26 | name => $user[username], |
26 | ensure => "present", | 27 | uid => $user[userid], |
27 | groups => $user[groups], | 28 | ensure => "present", |
28 | managehome => true, | 29 | groups => $user[groups], |
29 | system => !!$user[system], | 30 | managehome => true, |
30 | home => "/home/${user[username]}", | 31 | system => !!$user[system], |
31 | notify => Exec["remove_password:${user[username]}:${user[userid]}"], | 32 | home => "/home/${user[username]}", |
32 | purge_ssh_keys => true | 33 | notify => Exec["remove_password:${user[username]}:${user[userid]}"], |
33 | } | 34 | purge_ssh_keys => true |
35 | } | ||
34 | 36 | ||
35 | exec { "remove_password:${user[username]}:${user[userid]}": | 37 | exec { "remove_password:${user[username]}:${user[userid]}": |
36 | command => "/usr/bin/chage -d 0 ${user[username]} && /usr/bin/passwd -d ${user[username]}", | 38 | command => "/usr/bin/chage -d 0 ${user[username]} && /usr/bin/passwd -d ${user[username]}", |
37 | onlyif => "/usr/bin/test -z '${user[password]}'", | 39 | onlyif => "/usr/bin/test -z '${user[password]}'", |
38 | refreshonly => true | 40 | refreshonly => true |
41 | } | ||
39 | } | 42 | } |
40 | 43 | ||
41 | if has_key($user, "keys") { | 44 | if has_key($user, "keys") { |
42 | $user[keys].each |$key| { | 45 | $user[keys].each |$key| { |
43 | ssh_authorized_key { "${user[username]}@${key[host]}": | 46 | if has_key($key, "command") { |
44 | name => "${user[username]}@${key[host]}", | 47 | ssh_authorized_key { "${user[username]}@${key[host]}": |
45 | user => $user[username], | 48 | name => "${user[username]}@${key[host]}", |
46 | type => $key[key_type], | 49 | user => $user[username], |
47 | key => $key[key], | 50 | type => $key[key_type], |
51 | key => $key[key], | ||
52 | options => [ | ||
53 | "command=\"${key[command]}\"", | ||
54 | "no-port-forwarding", | ||
55 | "no-X11-forwarding", | ||
56 | "no-pty", | ||
57 | ], | ||
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], | ||
65 | } | ||
48 | } | 66 | } |
49 | } | 67 | } |
50 | } | 68 | } |