我来自Puppet 3,并尝试在新的Puppet 6系统上重建代码。我尝试给我的Agentnodes某种“ stage_level”,例如生产或测试。希拉无法找到此stage_level,尽管它已在希拉文件中设置。
stage_level是在我的Nodedefinition中设置的,Hiera应该能够找到它。查找本身在模块“ Facter”的init.pp中,该模块在Agentnodes上部署三个文件。
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'
role: xyz
stage_level: production
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找不到我在Nodedefinition中设置的stage_level。我认为问题出在定义中,我不得不重写它,因为这实际上是来自Puppet 3的代码。 预期的结果是在我的Agentnode上的文件/etc/facts/facter.d/stage_level.yaml下,以“生产”为内容。
感谢您的帮助