7551e1cfa1
Before we had set gid and uid to unset by default. Which if not overridden will have puppet try to set the gid and uid values to 'unset'. This should be an error as 'unset' is not a number. We don't have this error because we always override these values when creating localusers. But for completeness and better error messages remove the default values so that puppet requires users to have proper gid and uid values. Change-Id: I14667912b9239ea1c56123c18b0c13834f9c3cb6
52 lines
960 B
Puppet
52 lines
960 B
Puppet
# usage
|
|
#
|
|
# user::virtual::localuser['username']
|
|
|
|
define user::virtual::localuser(
|
|
$realname,
|
|
$uid,
|
|
$gid,
|
|
$groups = [ 'sudo', 'admin', ],
|
|
$sshkeys = '',
|
|
$key_id = '',
|
|
$old_keys = [],
|
|
$shell = '/bin/bash',
|
|
$home = "/home/${title}",
|
|
$managehome = true
|
|
) {
|
|
|
|
group { $title:
|
|
ensure => present,
|
|
gid => $gid,
|
|
}
|
|
|
|
user { $title:
|
|
ensure => present,
|
|
comment => $realname,
|
|
uid => $uid,
|
|
gid => $gid,
|
|
groups => $groups,
|
|
home => $home,
|
|
managehome => $managehome,
|
|
membership => 'minimum',
|
|
shell => $shell,
|
|
require => Group[$title],
|
|
}
|
|
|
|
ssh_authorized_key { $key_id:
|
|
ensure => present,
|
|
key => $sshkeys,
|
|
user => $title,
|
|
type => 'ssh-rsa',
|
|
}
|
|
|
|
if ( $old_keys != [] ) {
|
|
ssh_authorized_key { $old_keys:
|
|
ensure => absent,
|
|
user => $title,
|
|
}
|
|
}
|
|
}
|
|
|
|
# vim:sw=2:ts=2:expandtab:textwidth=79
|