Skip to content

Commit d66ea94

Browse files
committed
Created example accounts profile and updated Puppetfile to include puppetlabs/accounts
rewrote accounts profile to utilize iteration
1 parent 3cb1995 commit d66ea94

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed

Puppetfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ mod "puppetlabs/stdlib", '4.11.0'
77
mod "puppetlabs/concat", '2.1.0'
88
mod "hunner/hiera", '2.0.1'
99
mod "npwalker/pe_code_manager_webhook", '1.0.8'
10+
mod "puppetlabs/accounts", '1.0.0'
1011

1112
# Modules from Github using various references
1213
# Further examples: https://github.com/puppetlabs/r10k/blob/master/doc/puppetfile.mkd#examples

site/profile/manifests/accounts.pp

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# This class wraps the puppetlabs/accounts module and the native
2+
# group type to create accounts and groups from hiera.
3+
#
4+
# Enteries in Hiera should look like this:
5+
#
6+
# accounts_hash:
7+
# bob:
8+
# uid: '4001'
9+
# gid: '4001'
10+
# shell: '/bin/bash'
11+
# password: '!!'
12+
# sshkeys:
13+
# - 'ssh-rsa AAAA...'
14+
# locked: false
15+
# sue:
16+
# uid: '4002'
17+
# gid: '4002'
18+
# shell: '/bin/ksh'
19+
# password: '!!'
20+
# sshkeys:
21+
# - 'ssh-rsa BBBB...'
22+
# locked: false
23+
class profile::accounts (
24+
$accounts = hiera_hash('accounts_hash',{}),
25+
$groups = hiera_hash('groups_hash',{}),
26+
) {
27+
28+
$accounts.each |$key, $value| {
29+
accounts::user { $key:
30+
ensure => $value['ensure'],
31+
shell => $value['shell'],
32+
comment => $value['comment'],
33+
home => $value['home'],
34+
home_mode => $value['home_mode'],
35+
uid => $value['uid'],
36+
gid => $value['gid'],
37+
groups => $value['groups'],
38+
membership => $value['membership'],
39+
password => $value['password'],
40+
locked => $value['locked'],
41+
sshkeys => $value['sshkeys'],
42+
managehome => $value['managehome'],
43+
bashrc_content => $value['bashrc_content'],
44+
bash_profile_content => $value['bash_profile_content'],
45+
}
46+
}
47+
48+
$groups.each |$key, $value| {
49+
group { $key:
50+
ensure => $value['ensure'],
51+
allowdupe => $value['allowdupe'],
52+
attribute_membership => $value['attribute_membership'],
53+
attributes => $value['attributes'],
54+
auth_membership => $value['auth_membership'],
55+
forcelocal => $value['forcelocal'],
56+
gid => $value['gid'],
57+
ia_load_module => $value['ia_load_module'],
58+
members => $value['members'],
59+
provider => $value['provider'],
60+
system => $value['system'],
61+
}
62+
}
63+
}

0 commit comments

Comments
 (0)