Puppet的server端與agent端的通信建立

          puppet 的安裝與配置,請(qǐng)看上一篇文章。
          這里默認(rèn)你已經(jīng)把它安裝好了。

          想讓兩臺(tái)(或N臺(tái))機(jī)器相互通信,先要設(shè)置它們之間的Host文件。
          每一臺(tái)機(jī)器分別執(zhí)行如下命令
          sudo vi /etc/hosts
          把要相互通信的所有機(jī)器的IP 和 別名添加進(jìn)來(lái)。比如先以server端為例
          127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
          ::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
          10.23.10.237 puppet-server.noah.blogjava.net
          #上面可能是打開這個(gè)文件里默認(rèn)的,不用管,直接在下面加agent的ip就可以了,有多少加多少。
          10.52.27.71 agent001.noah-test.net
          10.52.27.72 agent002.noah-test.net
          10.52.27.73 agent003.noah-test.net
          接下來(lái)把上面的都復(fù)制,然后,分別考到其它的機(jī)器里面。

          接下來(lái)回到agent端,配置puppet 的配置文件,執(zhí)行如下命令
          sudo vi /etc/puppetlabs/puppet/puppet.conf
          在打開的文件里面填寫如下信息
          [main]
          #這個(gè)certname就是上面host里面的名字
          certname = agent001.noah-test.net
          #server 就是puppet的server的地址
          server = puppet-server.noah.blogjava.net
          environment 
          = production
          runinterval 
          = 1h


          然后在agent端,執(zhí)行如下命令,向server端申請(qǐng)證書
          sudo /opt/puppetlabs/bin/puppet agent --test
          然后,會(huì)出現(xiàn)這樣的信息
          Info: Creating a new SSL key for agent01.noah-test
          Info: Caching certificate for ca
          Info: csr_attributes file loading from /etc/puppetlabs/puppet/csr_attributes.yaml
          Exiting; no certificate found and waitforcert is disabled

          證明,申請(qǐng)成功,等待server端同意。這時(shí)可以轉(zhuǎn)到server端,執(zhí)行如下命令查看如些機(jī)器要申請(qǐng)證書
          sudo /opt/puppetlabs/bin/puppet cert list --all
          這里會(huì)顯示出所有申請(qǐng)過(guò)的和正在等待審批的agent的certname 的名字。審批通過(guò)的前面有個(gè)“+”。
          接下來(lái)執(zhí)行如下命令進(jìn)行單獨(dú)審批
           
          sudo /opt/puppetlabs/bin/puppet cert sign agent001.noah-test.net

          也可以直接在sgin 后面加 "--all",進(jìn)行全部審批。

          審批完成后,再回到agent端,執(zhí)行同樣的命令
          sudo /opt/puppetlabs/bin/puppet agent --test

          如下顯示的全是類似如下綠色的信息,證明它們之間的通信已經(jīng)建立成功
          Info: Using configured environment 'production'
          Info: Retrieving pluginfacts
          Info: Retrieving plugin
          Info: Caching catalog for agent001.noah-test.net
          Info: Applying configuration version '1481877703'







          問(wèn)題匯總:
          cloud@cdt-dev-cafews-yabinx:/etc/puppetlabs/puppet> sudo puppet agent -t
          Warning: Setting 'pluginsync' is deprecated.
          (at /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/defaults.rb:1713:in `block in <module:Puppet>')
          Warning: Unable to fetch my node definition, but the agent run will continue:
          Warning: getaddrinfo: Name or service not known
          Info: Retrieving pluginfacts
          Error: /File[/var/lib/puppet/facts.d]: Failed to generate additional resources using 'eval_generate': getaddrinfo: Name or service not known
          Error: /File[/var/lib/puppet/facts.d]: Could not evaluate: Could not retrieve file metadata for puppet:///pluginfacts: getaddrinfo: Name or service not known
          Info: Retrieving plugin
          Error: /File[/var/lib/puppet/lib]: Failed to generate additional resources using 'eval_generate': getaddrinfo: Name or service not known
          Error: /File[/var/lib/puppet/lib]: Could not evaluate: Could not retrieve file metadata for puppet:///plugins: getaddrinfo: Name or service not known
          Info: Loading facts
          Error: Could not retrieve catalog from remote server: getaddrinfo: Name or service not known
          Warning: Not using cache on failed catalog
          Error: Could not retrieve catalog; skipping run
          Error: Could not send report: getaddrinfo: Name or service not known
          用的命令不對(duì),改用這個(gè)
          sudo /opt/puppetlabs/bin/puppet agent --test



          sudo/opt/puppetlabs/bin/puppet agent --test
          Warning: Unable to fetch my node definition, but the agent run will continue:
          Warning: Server hostname 'cdt-dev-cafews-yabinx' did not match server certificate; expected one of cdt-dev-cafews-yabinx.emea1.cis.trcloud, DNS:puppet, DNS:cdt-dev-cafews-yabinx.emea1.cis.trcloud
          Info: Retrieving pluginfacts
          Error: /File[/opt/puppetlabs/puppet/cache/facts.d]: Failed to generate additional resources using 'eval_generate': Server hostname 'cdt-dev-cafews-yabinx' did not match server certificate; expected one of cdt-dev-cafews-yabinx.emea1.cis.trcloud, DNS:puppet, DNS:cdt-dev-cafews-yabinx.emea1.cis.trcloud
          Error: /File[/opt/puppetlabs/puppet/cache/facts.d]: Could not evaluate: Could not retrieve file metadata for puppet:///pluginfacts: Server hostname 'cdt-dev-cafews-yabinx' did not match server certificate; expected one of cdt-dev-cafews-yabinx.emea1.cis.trcloud, DNS:puppet, DNS:cdt-dev-cafews-yabinx.emea1.cis.trcloud
          Info: Retrieving plugin
          Error: /File[/opt/puppetlabs/puppet/cache/lib]: Failed to generate additional resources using 'eval_generate': Server hostname 'cdt-dev-cafews-yabinx' did not match server certificate; expected one of cdt-dev-cafews-yabinx.emea1.cis.trcloud, DNS:puppet, DNS:cdt-dev-cafews-yabinx.emea1.cis.trcloud
          Error: /File[/opt/puppetlabs/puppet/cache/lib]: Could not evaluate: Could not retrieve file metadata for puppet:///plugins: Server hostname 'cdt-dev-cafews-yabinx' did not match server certificate; expected one of cdt-dev-cafews-yabinx.emea1.cis.trcloud, DNS:puppet, DNS:cdt-dev-cafews-yabinx.emea1.cis.trcloud
          Error: Could not retrieve catalog from remote server: Server hostname 'cdt-dev-cafews-yabinx' did not match server certificate; expected one of cdt-dev-cafews-yabinx.emea1.cis.trcloud, DNS:puppet, DNS:cdt-dev-cafews-yabinx.emea1.cis.trcloud
          Warning: Not using cache on failed catalog
          Error: Could not retrieve catalog; skipping run
          Error: Could not send report: Server hostname 'cdt-dev-cafews-yabinx' did not match server certificate; expected one of cdt-dev-cafews-yabinx.emea1.cis.trcloud, DNS:puppet, DNS:cdt-dev-cafews-yabinx.emea1.cis.trcloud
          其實(shí)它已經(jīng)告訴你了,改一下/etc/hosts就可以了,改成下面的其中一個(gè)
          expected one of cdt-dev-cafews-yabinx.emea1.cis.trcloud, DNS:puppet, DNS:cdt-dev-cafews-yabinx.emea1.cis.trcloud




          sudo /opt/puppetlabs/bin/puppet agent --test
          Warning: Unable to fetch my node definition, but the agent run will continue:
          Warning: SSL_connect returned=1 errno=0 state=error: certificate verify failed: [unable to get local issuer certificate for /CN=cdt-dev-cafews-yabinx2.emea1.cis.trcloud]
          Info: Retrieving pluginfacts
          Error: /File[/opt/puppetlabs/puppet/cache/facts.d]: Failed to generate additional resources using 'eval_generate': SSL_connect returned=1 errno=0 state=error: certificate verify failed: [unable to get local issuer certificate for /CN=cdt-dev-cafews-yabinx2.emea1.cis.trcloud]
          Error: /File[/opt/puppetlabs/puppet/cache/facts.d]: Could not evaluate: Could not retrieve file metadata for puppet:///pluginfacts: SSL_connect returned=1 errno=0 state=error: certificate verify failed: [unable to get local issuer certificate for /CN=cdt-dev-cafews-yabinx2.emea1.cis.trcloud]
          Info: Retrieving plugin
          Error: /File[/opt/puppetlabs/puppet/cache/lib]: Failed to generate additional resources using 'eval_generate': SSL_connect returned=1 errno=0 state=error: certificate verify failed: [unable to get local issuer certificate for /CN=cdt-dev-cafews-yabinx2.emea1.cis.trcloud]
          Error: /File[/opt/puppetlabs/puppet/cache/lib]: Could not evaluate: Could not retrieve file metadata for puppet:///plugins: SSL_connect returned=1 errno=0 state=error: certificate verify failed: [unable to get local issuer certificate for /CN=cdt-dev-cafews-yabinx2.emea1.cis.trcloud]
          Error: Could not retrieve catalog from remote server: SSL_connect returned=1 errno=0 state=error: certificate verify failed: [unable to get local issuer certificate for /CN=cdt-dev-cafews-yabinx2.emea1.cis.trcloud]
          Warning: Not using cache on failed catalog
          Error: Could not retrieve catalog; skipping run
          Error: Could not send report: SSL_connect returned=1 errno=0 state=error: certificate verify failed: [unable to get local issuer certificate for /CN=cdt-dev-cafews-yabinx2.emea1.cis.trcloud]
          一般這種情況就是由于某種原因沒(méi)有認(rèn)證沒(méi)有成功,但它又不會(huì)重新認(rèn)證了,所以就報(bào)這個(gè)錯(cuò)誤,解決辦法是到這個(gè)目錄下/etc/puppetlabs/puppet,把生成的ssl文件夾給刪除,讓它重新生成一次key。如果生成一次還沒(méi)有成功的話,你要看一下是不是其它地方的問(wèn)題,然后,要重新重復(fù)上面的步驟,重新生成密鑰。



          眼鏡蛇

          posted on 2016-12-16 17:09 眼鏡蛇 閱讀(1876) 評(píng)論(0)  編輯  收藏 所屬分類: JavaPuppet

          <2025年6月>
          25262728293031
          1234567
          891011121314
          15161718192021
          22232425262728
          293012345

          導(dǎo)航

          統(tǒng)計(jì)

          常用鏈接

          留言簿(6)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          搜索

          最新評(píng)論

          閱讀排行榜

          評(píng)論排行榜

          主站蜘蛛池模板: 荥经县| 肥乡县| 松原市| 梅州市| 湖口县| 北流市| 石棉县| 织金县| 黑山县| 普安县| 加查县| 岚皋县| 遂宁市| 澄城县| 克拉玛依市| 乌鲁木齐县| 阳原县| 大安市| 扶余县| 乌兰县| 施甸县| 宜春市| 高阳县| 来宾市| 汾西县| 马尔康县| 福建省| 买车| 民权县| 玉门市| 赤峰市| 于都县| 甘泉县| 东乌珠穆沁旗| 开鲁县| 文成县| 南陵县| 洪雅县| 南木林县| 巴楚县| 石泉县|