Created
March 10, 2013 21:11
-
-
Save zined/5130435 to your computer and use it in GitHub Desktop.
cfengine3 user "management"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# adds users to the system | |
# | |
bundle agent add_users | |
{ | |
vars: | |
"pw[user1]" | |
string => "user1:x:10001:100:User1Name:/home/user1:/bin/sh"; | |
"shadow[user1]" | |
string => "user1::15056:0:99999:7:::"; | |
"keys[user1]" | |
string => "ssh-rsa XXXXXXXXXXXXXXXXXXXXXXXXXXXXX=="; | |
"pw[user2]" | |
string => "user2:x:10002:100:User1Name:/home/user2:/bin/sh"; | |
"shadow[user2]" | |
string => "user2::15056:0:99999:7:::"; | |
"keys[user2]" | |
string => "ssh-rsa XXXXXXXXXXXXXXXXXXXXXXXXXXXXX=="; | |
"users" | |
slist => getindices("pw"); | |
files: | |
"/etc/passwd" | |
edit_line => append_if_no_line("$(pw[$(users)])"); | |
"/etc/shadow" | |
edit_line => append_if_no_line("$(shadow[$(users)])"); | |
"/etc/group" | |
edit_line => append_user_field("users", "4", "@(add_users.users)"); | |
"/home/$(users)/." | |
create => "true", | |
perms => mog("755", "$(users)", "users"); | |
"/home/$(users)/.ssh/." | |
create => "true", | |
perms => mog("700", "$(users)", "users"); | |
"/home/$(users)/.ssh/authorized_keys" | |
create => "true", | |
perms => mog("600", "$(users)", "users"), | |
edit_line => append_if_no_line("$(keys[$(users)])"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment