是否有关于默认 Puppet 安装中包含的事实的参考?
例如,我看到的一些示例包括$operatingsystem
可用于识别分布。 有关于这些的参考资料吗?
答案1
您可能知道,这些都是由 facter 包提供的。通过facter
在 cli 上运行,您可以看到它所知道的所有事实:
architecture => i386
domain => <redacted>
facterversion => 1.3.8
fqdn => <redacted>
hardwareisa => unknown
hardwaremodel => i686
hostname => <redacted>
id => <redacted>
ipaddress => <redacted>
ipaddress_eth0 => <redacted>
kernel => Linux
kernelrelease => <redacted>
lsbdistcodename => hardy
lsbdistdescription => Ubuntu 8.04.4 LTS
lsbdistid => Ubuntu
lsbdistrelease => 8.04
macaddress => <redacted>
macaddress_eth0 => <redacted>
memoryfree => 336.51 MB
memorysize => 453.34 MB
operatingsystem => Debian
operatingsystemrelease => <redacted>
processor0 => Intel(R) Xeon(R) CPU L5335 @ 2.00GHz
processor1 => Intel(R) Xeon(R) CPU L5335 @ 2.00GHz
processor2 => Intel(R) Xeon(R) CPU L5335 @ 2.00GHz
processor3 => Intel(R) Xeon(R) CPU L5335 @ 2.00GHz
processorcount => 4
ps => ps -ef
rubysitedir => /usr/local/lib/site_ruby/1.8
rubyversion => 1.8.6
sshdsakey => <redacted>
sshrsakey => <redacted>
swapfree => 210.98 MB
swapsize => 256.00 MB
uniqueid => <redacted>
答案2
哦,刚刚发现最简单的方法就是facter
从命令行运行。这会输出键值对的列表:
root@ny-man01:/etc/puppet/files# facter
architecture => x86_64
domain => ny.stackoverflow.com
facterversion => 1.5.7
fqdn => ny-man01.ny.stackoverflow.com
hardwareisa => unknown
hardwaremodel => x86_64
hostname => ny-man01
...
...
来源:https://puppet.com/docs/puppet/latest/lang_variables.html
答案3
对于 Linux 发行版,您还需要确保安装了 LSB 发行信息包。在 Red Hat 和 Fedora 发行版中,此包非常简单lsb-release
如果 Linux 上没有这个包,facter 提供的信息将会非常简单。
答案4
facter
一些 Facter 事实仅当以 root 身份运行时才可用:
$ diff <(facter) <(sudo facter)
28a29
> manufacturer => Supermicro
48a50
> productname => X8SIE
53a56
> serialnumber => 0123456789
58a62
> type => Sealed-case PC
很多时候,这些是通过 BIOS 检查等得出的事实dmidecode
是普通用户无法运行的。