Skip to content

Instantly share code, notes, and snippets.

@brettswift
Created October 16, 2015 12:27
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 brettswift/efb777189e738a1f8dec to your computer and use it in GitHub Desktop.
Save brettswift/efb777189e738a1f8dec to your computer and use it in GitHub Desktop.
Puppet Accounts module
class accounts (
$virtual_accounts = {},
$defaults = {},
) {
$realize = hiera_array('accounts')
group { 'sudo-dev':
ensure => present,
gid => 514,
}
create_resources('@accounts::virtual', $virtual_accounts, $defaults)
realize (Accounts::Virtual[$realize])
}
define accounts::virtual (
$uid = undef,
$comment = undef,
$password = undef,
) {
user { $title:
ensure => 'present',
uid => $uid,
gid => $title,
shell => '/bin/bash',
home => "/home/${title}",
comment => $comment,
groups => ['sudo-dev'],
password => $password,
managehome => true,
}
group { $title:
gid => $uid,
}
}
accounts:
- user_one
- user_two
accounts::defaults: #unknown
password: '$6$5COqysSv$3x5pUIOg/xxr0KmYKtsdBio.Y7b7CveWVSaZ3/jVrDgtmHrHkwZkHIh5ckyY3AmCR0Fz.zM4o9X/MMkFhsWYf0'
accounts::virtual_accounts:
'user_one':
uid: 6246
comment: 'User One'
password: 'paste in a (partial) hash from /etc/shadow'
'user_two':
uid: 6247
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment