我对Ruby一无所知,刚开始探索Puppet并想创建自定义事实,首先,请使用网上发现的事实来查看其工作原理:
将下面的代码复制到/etc/puppetlabs/code/environments/production/modules/dsc/lib/facter/windows.rb
(dsc是模块名称)
Facter.add(:ismsclusternode) do
confine :kernel => 'windows'
sysnativedir = Facter.value(:system32)
setcode do
if Facter::Util::Resolution.exec(sysnativedir +
'\WindowsPowerShell\v1.0\powershell.exe "(get-windowsfeature
-Name Failover-Clustering).Installed"') == "True"
true
else
false
end
end
end
来自代理输出:
Info: Facter: loading custom facts from C:/ProgramData\PuppetLabs\puppet\cache\lib\facter\windows.rb.
Debug: Facter: executing command: C:\Windows\system32\cmd.exe /c C:\Windows\System32\Wbem\wmic.exe ComputerSystem get SystemType | FindStr /i x
Debug: Facter: x64-based PC
Debug: Facter: process exited with exit code 0.
Debug: Facter: searching for custom facts in C:/ProgramData\PuppetLabs\puppet\cache\lib\facter.
Debug: Facter: custom fact "common_appdata" was not found.
Error: Facter: error while resolving custom fact "_puppet_inventory_1": no implicit conversion of nil into String
Debug: Facter: fact "_puppet_inventory_1" resolved to null and will not be added.
Error: Facter: error while resolving custom fact "_puppet_inventory_1": no implicit conversion of nil into String
Error: Failed to apply catalog: Parameter path failed on File[/PuppetLabs/pxp-agent/etc/pxp-agent.conf]: File paths must be fully qualified, not '/PuppetLabs/pxp-agent/etc/pxp-agent.conf' (file: /opt/puppetlabs/puppet/modules/puppet_enterprise/manifests/pxp_agent.pp, line: 87)
/opt/puppetlabs/puppet/modules/puppet_enterprise/manifests/pxp_agent.pp,第87行:
file { "${puppet_enterprise::params::pxp_agent_etc}/pxp-agent.conf":
puppetserver version: 2018.1.0.54
puppet --version
5.5.2