
我正在透過 gems(在 rhel6 上)在 ec2 中設定 puppetmaster(2.7.6),並且我遇到了憑證名稱問題以及讓 master 能夠與自身對話的問題。
我的 puppet.conf 看起來像這樣:
[main]
logdir = /var/log/puppet
rundir = /var/run/puppet
vardir = /var/lib/puppet
ssldir = $vardir/ssl
pluginsync = true
environment = production
report = true
certname = master
當我啟動 puppetmaster 進程時,ssl 目錄如下:
ssl/private_keys/master.pem
ssl/crl.pem
ssl/public_keys/master.pem
ssl/ca/ca_crl.pem
ssl/ca/signed/master.pem
ssl/ca/ca_crt.pem
ssl/ca/ca_pub.pem
ssl/ca/ca_key.pem
ssl/certs/ca.pem
ssl/certs/master.pem
我在盒子上有一個 /etc/hosts 條目,將“puppet”主機名稱指向本地主機,這樣我就不必更改“伺服器”選項。
當我運行代理時,我得到以下資訊:
# puppet agent --test
info: Retrieving plugin
err: /File[/var/lib/puppet/lib]: Failed to generate additional resources using 'eval_generate: Server hostname 'puppet' did not match server certificate; expected master
err: /File[/var/lib/puppet/lib]: Could not evaluate: Server hostname 'puppet' did not match server certificate; expected master Could not retrieve file metadata for puppet://puppet/plugins: Server hostname 'puppet' did not match server certificate; expected master
err: Could not retrieve catalog from remote server: Server hostname 'puppet' did not match server certificate; expected master
warning: Not using cache on failed catalog
err: Could not retrieve catalog; skipping run
err: Could not send report: Server hostname 'puppet' did not match server certificate; expected master
如果我將憑證名稱指定為伺服器(帶有相應的主機條目),我會得到:
# puppet agent --test --server master
info: Retrieving plugin
err: /File[/var/lib/puppet/lib]: Could not evaluate: Could not retrieve information from environment production source(s) puppet://master/plugins
info: Caching catalog for master
info: Applying configuration version '1321805956'
notice: Finished catalog run in 0.05 seconds
這是某種成功,當我應用清單時,來源錯誤會困擾我。我嘗試了使用 ec2 私有主機名稱的其他一些變體,並得到了不同的結果。
我想避免設定 server = 'x' 並使用 dns/hosts 來控制 'puppet' 解析的內容,以便決定哪個伺服器(更容易使用可用區域等)
答案1
經過一番調查後,我弄清楚了這一點。 Puppet 2.7.6 在為主伺服器產生憑證時不會在伺服器憑證上設定 subjectAltNames(它實際上在任何時候都不知道自己是主伺服器)。
有兩種方法可以修正此問題:
1.手動產生master的證書
puppet ca generate --dns_alt_names puppet [master-name/uuid/string/etc]
2.在puppet.conf中設定dns_alt_names
在執行 puppet master 或 puppet 之前新增dns_alt_names = puppet
至 master(並且僅包含 master)(導致產生憑證)
現在,使用 /etc/hosts 或 dns 條目連接到「puppet」就可以正常工作了。
與插件相關的另一個錯誤是啟用了插件同步但沒有可用於同步的插件的錯誤。
答案2
certname = master
您已將 certname 設定為 master。對於設定方式,要么讓它與 puppet 一起工作,要么使用主機檔案設定 master 而不是 puppet 的 IP 位址。
您可能還想使用 FQDN,例如 master.example.com 或 puppet.example.com,這樣您就可以使用 dns 條目,而無需搜尋網域條目。
答案3
在 EC2 中使用 puppet 的一個技巧是將 ElasticIP 指派給您的 puppetmaster,然後為 ElasticIP CNAME 建立一個 DNS 條目,而不是為該 IP 建立 A 記錄。
AWS DNS 伺服器會根據查詢來自相同 EC2 區域或外部來變更其回應。如果 CNAME 請求來自 EC2 區域內,AWS DNS 伺服器將使用 CNAME 的內部 IP 進行回應。
您應該在 DNS 中使用 CNAME,以便當 EC2 puppet 用戶端向 AWS DNS 伺服器查詢 Puppetmaster 的 IP 時,它們將收到回應,將其導向至 puppetmaster 的內部 IP,而不是外部 IP。