I'm coming from Puppet 3 and try to rebuild my code on a new Puppet 6 system. I try to give my Agentnodes some sort of "stage_level" like productive or testing. Hiera can't find this stage_level although it is set in a Hiera file.
The stage_level is set in my Nodedefinition and Hiera should be able to find it. The lookup itself is in the init.pp from a Module "Facter" which deploys three files on the Agentnodes.
hiera.yaml
version: 5
defaults:
datadir: /etc/puppetlabs/code/environments/production/data/
data_hash: yaml_data
hierarchy:
- name: 'Global Config'
path: global.yaml
- name: 'Nodes'
path: 'nodes/%{trusted.certname}.yaml'
A Nodedefinition in data/nodes/server.xyz.com.yaml
role: xyz
stage_level: production
init.pp from modules/facter/manifests/
define facter::set_av_facter {
$facter_value = hiera($name,'no_default_value')
file { "/etc/facter/facts.d/${name}.yaml":
ensure => present,
owner => 'root',
group => 'root',
mode => '0644',
content => inline_template("# This file is managed by puppet\n${name}: ${facter_value}\n"),
}
}
class facter {
file { '/etc/facter':
ensure => directory,
owner => 'root',
group => 'root',
mode => '0755',
}
file { '/etc/facter/facts.d':
ensure => directory,
owner => 'root',
group => 'root',
mode => '0755',
}
$av_facter = [
'role',
'stage_level',
]
facter::set_av_facter{$av_facter:}
file { "/etc/facter/facts.d/patchlevel.yaml":
ensure => absent,
}
}
Hiera can't find the stage_level that i set in the Nodedefinition. I think the problem is in the define, which i had to rewrite because this was actually code from Puppet 3. Expected outcome is a file on my Agentnode under /etc/facts/facter.d/stage_level.yaml with "production" as content.
Any help is appreciated