First, you have to declare your ssh_keys
, users
and usergroups
hashes:
class { 'accounts':
ssh_keys => lookup('accounts::ssh_keys', Hash, 'hash', {}),
users => lookup('accounts::users', Hash, 'hash', {}),
usergroups => lookup('accounts::usergroups', 'Hash, 'hash', {}),
}
Example hiera YAML file:
---
accounts::ssh_keys:
foo:
type: ssh-rsa
public: FOO-S-RSA-PUBLIC-KEY
bar:
type: ssh-rsa
public: BAR-S-RSA-PUBLIC-KEY
accounts::users:
foo:
uid: 1000
comment: Foo
bar:
uid: 1001
comment: Bar
baz:
# Remove user baz from every node (unless overridden)
ensure: absent
qux:
uid: 1003
comment: Qux
accounts::usergroups:
foo:
- foo
- bar
bar:
- baz
- qux
Then you can create accounts on your node with the accounts::account
defined type.
accounts::account { 'foo': }
Creates a foo
user if it exists in $::accounts::users
and at allow its public key if it exists in $::accounts::ssh_keys
.
accounts::account { 'bar':
authorized_keys => ['@foo', 'baz'],
}
Creates a bar
user if it exists in $::accounts::users
and at allow its public key, everyone's in thefoo
usergroup's public key and baz
's one if it exists in $::accounts::ssh_keys
.
accounts::account { '@foo': }
Create a user for every user in foo
usergroup and allow its public key.
Hash of groups to create (passed to create_resources
). Defaults to {}
.
Default value for the users' membership
parameter. Refer to the Puppet documentation for more information.
Hash of SSH public keys that can be assigned to users (see Usage above).
Hash of users (see Usage above).
Hash of user groups (see Usage above).
Hash of accounts to create (see Usage above).
Set the resource "user" parameter so that the users are not created/supressed in external user directories (i.e. LDAP).
Sets the lowest uid for non system users. This is a system setting and also affects users created outside of this module.
Sets the lowest gid for non system groups. This is a system setting and also affects groups or users created outside of this module.
Default value for users' purge_ssh_keys
parameter. When true
all SSH keys in a users authorized_keys
file not managed by Puppet will be deleted. Defaults to false
.
Default value for users' shell
parameter. Default is the system default (usually /bin/sh
).