我正在尝试使用最新的 Amazon Linux AMI 在 AWS EC2 上设置一个简单的 Puppet 设置。
我已经按照安装指南进行了红帽企业版并运行puppetmasterd
守护进程。
当应用以下清单时/etc/puppet/manifests/site.pp
:
node 'ip-172-31-1-239.eu-west-1.compute.internal' {
class { 'apache': }
}
我收到错误:
[ec2-user@ip-172-31-1-239 ~]$ sudo puppet agent --test
info: Loading facts in /etc/puppet/modules/concat/lib/facter/concat_basedir.rb
info: Loading facts in /etc/puppet/modules/stdlib/lib/facter/pe_version.rb
info: Loading facts in /etc/puppet/modules/stdlib/lib/facter/root_home.rb
info: Loading facts in /etc/puppet/modules/stdlib/lib/facter/facter_dot_d.rb
info: Loading facts in /etc/puppet/modules/stdlib/lib/facter/puppet_vardir.rb
err: Could not retrieve catalog from remote server: Error 400 on SERVER: Class['apache::version']: Unsupported osfamily: Linux at /etc/puppet/modules/apache/manifests/version.pp:37 on node ip-172-31-1-239.eu-west-1.compute.internal
warning: Not using cache on failed catalog
err: Could not retrieve catalog; skipping run
从version.pp
Puppet 的 Apache 模块我可以看到为什么清单无法安装 Apache,但我不明白为什么 Facterosfamily
首先将其报告为“Linux”:
[ec2-user@ip-172-31-1-239 ~]$ facter | grep osfamily
osfamily => Linux
[ec2-user@ip-172-31-1-239 ~]$ rpm -qa | grep facter
facter-1.6.18-7.25.amzn1.noarch
[ec2-user@ip-172-31-1-239 ~]$ rpm -qa | grep puppet
puppetlabs-release-6-11.noarch
puppet-2.7.25-1.4.amzn1.noarch
puppet-server-2.7.25-1.4.amzn1.noarch
[ec2-user@ip-172-31-1-239 ~]$ sudo puppet module list
/etc/puppet/modules
├── puppetlabs-apache (v1.4.0)
├── puppetlabs-concat (v1.2.0)
└── puppetlabs-stdlib (v4.5.1)
/usr/share/puppet/modules (no modules installed)
有人知道我该如何解决这个问题吗?
答案1
不要使用 Amazon Linux。Puppet Labs Apache 模块与 Amazon Linux 不兼容。您需要使用与之兼容的发行版之一,或者创建自己的 Puppet 模块。
答案2
今天用全新的眼光审视之后,我发现 Facter v1.7.0 包含一个修复程序,可以正确地将 Amazon Linux 归类为“RedHat”:https://github.com/puppetlabs/facter/commit/c12d3b6c557df695a7b2b009da099f6a93c7bd31
现在我知道为什么它会被错误地报告,我需要知道为什么我没有从 PuppetLabs Yum repo 安装 Facter v1.7.0,这超出了这个问题的范围。
答案3
问题似乎出在文件中/usr/lib/ruby/site_ruby/1.8/facter/osfamily.rb
在 Amazon Linux 的情况下,最终使用 osoperatingsystem 作为 osfamily。
第 19 行是:
when "RedHat", "Fedora", "CentOS", "Scientific", "SLC", "Ascendos", "CloudLinux", "PSBM", "OracleLinux", "OVS", "OEL"
应该是:
when "RedHat", "Fedora", "CentOS", "Scientific", "SLC", "Ascendos", "CloudLinux", "PSBM", "OracleLinux", "OVS", "OEL", "Amazon"