Skip to content

Instantly share code, notes, and snippets.

@Yggdrasil
Created November 10, 2012 13:31
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 Yggdrasil/4051062 to your computer and use it in GitHub Desktop.
Save Yggdrasil/4051062 to your computer and use it in GitHub Desktop.
Puppet virtual users class
# Class: users
#
# This module manages users
#
# Parameters:
#
# Actions:
#
# Requires:
#
# Sample Usage:
#
# [Remember: No empty lines between comments and class definition]
class users {
define localuser (
$pass,
$shell="/bin/bash",
$groups=[],
$sshkey="",
$sshkeytype="ssh-rsa",
$ensure="present"
) {
$homedir = "/home"
$username = $title
user { $username:
ensure => $ensure,
shell => "${shell}",
home => "${homedir}/${title}",
comment => "${realname}",
password => "${pass}",
managehome => 'true',
groups => $groups,
}
if ( $sshkey != "" ) {
ssh_authorized_key { $title:
ensure => "present",
type => "${sshkeytype}",
key => "${sshkey}",
user => "${title}",
name => "${title}",
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment