In my puppet configuration, I've got a defined resource type as follows. Everything was working fine under puppet 2.7, but after an upgrade to puppet 3.8, I'm having trouble with it. When I create a user, the exec
runs without the user
and group
running first, so the exec resource's command fails to execute properly.
Can anyone explain what is going wrong?
define my_user (
$uid,
$fullname,
$email,
$group = $name,
$ingroups = [],
$shell = '/bin/bash',
$home = "/home/${name}",
$ensure = 'present',
$sudo = 'no',
$system_user = false,
$ssh_key = undef,
$ssh_key_type = undef,
) {
group{ $name:
ensure => present,
gid => $uid,
}
user { $name:
ensure => $ensure,
comment => $fullname,
uid => $uid,
gid => $group,
groups => $ingroups,
shell => $shell,
home => $home,
managehome => true,
require => Group[$group],
system => $system_user,
}
exec { "${name} homedir":
command => "/bin/cp -R /etc/skel ${home}; /bin/chown -R ${name}:${group} ${home}",
creates => $home,
require => User[$name],
}
file { "${home}/.ssh":
ensure => directory,
require => [ User[$name], Exec["${name} homedir"] ],
owner => $name,
group => $name,
mode => '0755',
}
if $ssh_key {
ssh_authorized_key{ $email:
ensure => $ensure,
user => $name,
key => $ssh_key,
type => $ssh_key_type,
}
}
}
0 Answers