-
Notifications
You must be signed in to change notification settings - Fork 0
/
users.cf
170 lines (141 loc) · 4.95 KB
/
users.cf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
bundle agent users
{
vars:
any::
#
# Groups to add:
#
"group[admins][gid]" string => "5000";
"group[developers][gid]" string => "5001";
#
# Users to add:
#
"user[tino.reinhardt][uid]" string => "5010";
"user[tino.reinhardt][group]" string => "admins";
"user[tino.reinhardt][shell]" string => "zsh";
#
# Users to modify:
#
#"moduser[tino.reinhardt][uid]" string => "5014";
#"moduser[tino.reinhardt][group]" string => "admins";
#"moduser[tino.reinhardt][shell]" string => "zsh";
#
# Users to delete:
#
#"nouser[knarf][uid]" string => "9000";
webnodes::
"group[deploy][gid]" string => "1001";
"group[app][gid]" string => "1002";
"user[deploy][uid]" string => "1001";
"user[deploy][group]" string => "Deploy user";
"user[deploy][shell]" string => "sh";
"user[app][uid]" string => "1002";
"user[app][group]" string => "App user";
"user[app][shell]" string => "sh";
git_1_b::
"group[git][gid]" string => "965";
"user[git][uid]" string => "965";
"user[git][group]" string => "git";
"user[git][shell]" string => "zsh";
files:
"/root/.ssh/authorized_keys"
perms => mo("644","root"),
copy_from => secure_cp (
"/cf-public/users/root/authorized_keys",
"$(sys.policy_hub)"
);
"/root/.ssh/authorized_keys2"
delete => tidy;
methods:
"group" usebundle => create_group("users.group");
"user" usebundle => create_user("users.user");
"ssh" usebundle => enable_ssh("users.user");
"moduser" usebundle => modify_user("users.moduser");
"nouser" usebundle => disable_user("users.nouser");
}
bundle agent create_group(groups)
{
vars:
"group" slist => getindices("$(groups)");
classes:
"add_$(group)" not => groupexists("$(group)");
commands:
freebsd::
"/usr/sbin/pw groupadd $(group) -g $($(groups)[$(group)][gid])"
ifvarclass => canonify("add_$(group)");
debian::
"/usr/sbin/groupadd -g $($(groups)[$(group)][gid]) $(group)"
ifvarclass => canonify("add_$(group)");
}
bundle agent create_user(users)
{
vars:
"user" slist => getindices("$(users)");
classes:
"add_$(user)" not => userexists("$(user)");
commands:
freebsd::
"/usr/sbin/pw useradd $(user) -c ''
-u $($(users)[$(user)][uid])
-g $($(users)[$(user)][group])
-s /usr/local/bin/$($(users)[$(user)][shell])"
ifvarclass => canonify("add_$(user)");
debian::
"/usr/sbin/useradd -c ''
-u $($(users)[$(user)][uid])
-g $($(users)[$(user)][group])
-s /bin/$($(users)[$(user)][shell]) $(user)"
ifvarclass => canonify("add_$(user)");
}
bundle agent modify_user(users)
{
vars:
"user" slist => getindices("$(users)");
commands:
freebsd::
"/usr/sbin/pw usermod $(user) -c ''
-u $($(users)[$(user)][uid])
-g $($(users)[$(user)][group])
-s /usr/local/bin/$($(users)[$(user)][shell])"
if => userexists("$(user)");
debian::
"/usr/sbin/usermod -c ''
-u $($(users)[$(user)][uid])
-g $($(users)[$(user)][group])
-s /bin/$($(users)[$(user)][shell]) $(user)"
if => userexists("$(user)");
}
bundle agent enable_ssh(users)
{
vars:
"user" slist => getindices("$(users)");
files:
"/home/$(user)/."
perms => mog("700","$(user)", "$($(users)[$(user)][group])"),
create => "true";
"/home/$(user)/.ssh/."
perms => mog("700","$(user)", "$($(users)[$(user)][group])"),
create => "true";
"/home/$(user)/.ssh/authorized_keys"
perms => mog("600","$(user)", "$($(users)[$(user)][group])"),
copy_from => secure_cp (
"/cf-public/users/$(user)/authorized_keys",
"$(sys.policy_hub)"
);
"/home/$(user)/.ssh/authorized_keys2"
delete => tidy;
}
bundle agent disable_user(names)
{
vars:
"user" slist => getindices("$(names)");
classes:
"disable_$(user)" if => userexists("$(user)");
commands:
freebsd::
"/usr/sbin/pw userdel $(user) -r"
ifvarclass => canonify("disable_$(user)");
debian::
"/usr/sbin/userdel -r $(user)"
ifvarclass => canonify("disable_$(user)");
}