Skip to content

Instantly share code, notes, and snippets.

@jerrac
Created May 8, 2013 21:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jerrac/5543893 to your computer and use it in GitHub Desktop.
Save jerrac/5543893 to your computer and use it in GitHub Desktop.
Rough draft of userwrapper puppet module
sshpubkeys/username.json
{
"type": "id_rsa",
"key": "really long key",
"name": "blah@blah"
}
sshpubkeys/reagand.json
{
"type": "id_rsa",
"key": "really long key",
"name": "blah@blah"
}
users/reagand.json
{
"userwrapper::username": "reagand",
"userwrapper::fullname": "David Reagan",
"userwrapper::ensure": "present",
"userwrapper::password": "hashedpass",
"userwrapper::authorizedSSHKeys": ["username","reagand"],
"userwrapper::email": "reagand@lanecc.edu",
"userwrapper::home": "/home/reagand",
"userwrapper::managehome": "true",
"userwrapper::shell": "/bin/bash",
"userwrapper::uid": "10001",
"userwrapper::groups": "developers"
}
init.pp
class userwrapper(
$username,
$fullname,
$ensure,
$password,
$authorizedSSHKeys,
$email,
$home,
$managehome,
$shell,
$uid,
$groups
)
{
user { $username:
comment => $username,
ensure => $ensure,
password => $password,
managehome => $managehome,
home => $home,
name => $username,
shell => $shell,
uid => $uid
}
# Do something with the groups to make sure we don't add nonexistent groups...
# read $authorizedSSHKeys
# if using example files...
# Grab sshpubkeys/reagand.json and sshpubkeys/username.json
# add a unique value to the name property
# run create_resources(ssh_authorized_key, $whatever is in the json file) for both keys.
}
node.pp
server.fqdn {
include userwrapper
create_resources(userwrapper,"reagand")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment