FreeBSD 13.1下Puppet内存Facts缺失及后续问题求助
我在FreeBSD 13.1上运行一台由Puppet管理的服务器。最近执行pkg upgrade后,puppet6被自动替换为puppet7,但这与我们现有基于Puppet 6的60台服务器环境不兼容。于是我从源码编译了Ruby 2.7,再通过Ruby Gem安装了puppet,这一步操作正常。
第一个问题:内存Fact无法解析
运行Puppet Agent时,无法解析Fact:$::memory['system']['total']
执行以下命令时出现错误:
$ sudo puppet agent --test
Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Resource Statement, Evaluation Error: Operator '[]' is not applicable to an Undef Value. [...]
为解决这个问题,我在$HOME/facter.d/memory.json中定义了自定义Fact:
{ "memory": { "system": { "total" : "32.00 GiB", "total_bytes" : 34359738368 } } }
测试该自定义Fact有效:
$ facter --external-dir $HOME/facter.d
[...]
memory => {
system => {
total => "32.00 GiB",
total_bytes => 34359738368
}
}
[...]
随后我在Puppet配置文件/etc/puppetlabs/puppet/puppet.conf中添加了如下配置:
factpath=/home/me/facter.d:/opt/puppetlabs/puppet/cache/lib/facter
其中/home/me即上述的$HOME目录,但问题依旧,错误完全相同。这是哪里出了问题?
更新:降级Facter后出现新错误
我现在将Facter降级到2.5.7版本,改用::memorysize后该Fact能正常工作,但执行sudo puppet agent --test时出现新错误:
Error: Failed to apply catalog: Resource type 'Ssh_authorized_key' was not found
内容的提问来源于stack exchange,提问作者Patrick Bucher

