Here is custom fact:
require 'etc'
Etc.passwd do |user|
Facter.add("homedir_#{user.name}".intern) do
setcode { user.dir }
end
end
It determine users home dir locations.
Here is defined type:
define ssh_keys::key ($user) {
$home = $::homedir_#{user}
if $home != undef {
file { "$home/.ssh/":
ensure => directory,
}
file { "$home/.ssh/authorized_keys":
ensure => file,
source => "puppet:///modules/ssh_keys/$user",
}
}
}
It does not work with $::homedir_#{user}
, but works with exactly defined fact: $::homedir_root
. What is wrong here?
Here is solution: