【puppet初識(shí)】
創(chuàng)新互聯(lián)公司2013年開創(chuàng)至今,是專業(yè)互聯(lián)網(wǎng)技術(shù)服務(wù)公司,擁有項(xiàng)目成都做網(wǎng)站、網(wǎng)站設(shè)計(jì)網(wǎng)站策劃,項(xiàng)目實(shí)施與項(xiàng)目整合能力。我們以讓每一個(gè)夢想脫穎而出為使命,1280元上思做網(wǎng)站,已為上家服務(wù),為上思各地企業(yè)和個(gè)人服務(wù),聯(lián)系電話:13518219792學(xué)習(xí)目錄 領(lǐng)導(dǎo)說saltstack太慢 機(jī)器量一旦上來,saltstack就力不從心,所以要將saltstack轉(zhuǎn)向puppet。
【安裝背景】
系統(tǒng)centos 6.5
軟件地址:
http://downloads.puppetlabs.com/puppet/
master: 192.168.100.10
agent: 192.168.100.13
因?yàn)閜uppet對(duì)ca證書的辦法是很對(duì)域名了。所以域名一定要解析并且master端最好不要變。
【安裝步驟】
時(shí)鐘同步
ntpdate pool.ntp.org
設(shè)置hostname并放入hosts解析
echo "192.168.100.10 master.test.com" >> /etc/hosts echo "192.168.100.13 agent.test.com" >> /etc/hostspuppet端master和agent端的安裝:
puppet是基于ruby的,所以首先要安裝ruby語言環(huán)境。
yum install ruby -y
安裝facter -->收集系統(tǒng)信息的軟件命令
################# master 和agent 共同的步驟 #############
tar xvf facter-1.6.13.tar.gz
cd facter-1.6.13
ruby install.rb
## 檢查facter安裝是否成功
facter 收集系統(tǒng)的信息的命令工具
tar xvf puppet-3.0.0.tar.gz
cd puppet-3.0.0
ruby install.rb
創(chuàng)建puppet 用戶否則啟動(dòng)失敗
useradd puppet
######################## master 拷貝配置
[root@master puppet-3.0.0]# pwd
/usr/local/src/puppet-3.0.0
[root@master puppet-3.0.0]# cp ext/redhat/server.init /etc/init.d/puppetmaster
[root@master puppet-3.0.0]# chmod 755 /etc/init.d/puppetmaster
cp ext/redhat/puppet.conf /etc/puppet/
######################## agent 拷貝配置
[root@agent puppet-3.0.0]# cp ext/redhat/client.init /etc/init.d/puppetclient
[root@agent puppet-3.0.0]# chmod 755 /etc/init.d/puppetclient
##### master啟動(dòng)
/etc/init.d/puppetmaster start
#### master啟動(dòng)檢測
[root@master puppet-3.0.0]# ps -ef |grep ruby
puppet 10915 1 1 16:34 ? 00:00:01 /usr/bin/ruby /usr/bin/puppet master
root 11272 6458 0 16:36 pts/0 00:00:00 grep --color=auto ruby
[root@master puppet-3.0.0]# netstat -tulnp |grep ruby
tcp 0 0 0.0.0.0:8140 0.0.0.0:* LISTEN 10915/ruby
##### agent 啟動(dòng)
[root@agent puppet-3.0.0]# /etc/init.d/puppetclient start
Starting puppet agent:
#### agent 啟動(dòng)檢測
[root@agent puppet-3.0.0]# ps -ef |grep ruby
root 5623 1 5 16:40 ? 00:00:02 /usr/bin/ruby /usr/bin/puppet agent
############## agent 請(qǐng)求證書 master簽發(fā)證書
agent request agent端向maser端發(fā)起證書請(qǐng)求 puppet agent --test --server master.test.com
master accept puppet cert sign agent.test.com 接收指定的 puppet cert sign --all 接收所有的請(qǐng)求
agent fetch
過程1
[root@agent puppet-3.0.0]# puppet agent --test --server master.test.com
Info: Caching certificate for ca
Info: Creating a new SSL certificate request for agent.test.com
Info: Certificate Request fingerprint (SHA256): DB:AC:CB:4E:FC:68:E3:71:B5:45:6E:6C:73:C9:EE:27:11:0F:2D:5A:8F:43:21:53:0D:33:7F:85:87:4B:0E:59
Exiting; no certificate found and waitforcert is disabled
[root@agent puppet-3.0.0]#
過程2:
master端已經(jīng)有這個(gè)請(qǐng)求了 接受就可以了
[root@master puppet]# puppet cert list 或者 puppet cert list --all
"agent.test.com" (SHA256) DB:AC:CB:4E:FC:68:E3:71:B5:45:6E:6C:73:C9:EE:27:11:0F:2D:5A:8F:43:21:53:0D:33:7F:85:87:4B:0E:59
[root@master puppet]#
接收證書:
[root@master puppet]# puppet cert sign agent.test.com
Signed certificate request for agent.test.com
Removing file Puppet::SSL::CertificateRequest agent.test.com at '/var/lib/puppet/ssl/ca/requests/agent.test.com.pem'
過程3:
agent端測試
puppet agent --test --server master.test.com############### 出錯(cuò)過程 ##########
[root@agent puppet-3.0.0]# puppet agent --test
Error: Could not request certificate: Connection refused - connect(2)
Exiting; failed to retrieve certificate and waitforcert is disabled
我這里的原因是 agent的使用的都是默認(rèn)配置 沒有知道指定master 解決方法:
puppet agent --test --server master.test.com
排除了網(wǎng)絡(luò)問題的命令: telnet master.test.com 8140
####### 寫一個(gè)測試用例 測試 master 和 agnet可以通信了 及 master可以管理agent端了 agent可以同步master端了
master端編寫一個(gè)測試pp
[root@master manifests]# cat site.pp
file { "/tmp/temp1.txt":
content => "Hello World\n"; }
[root@master manifests]# pwd
/etc/puppet/manifests
### agent 進(jìn)行同步
[root@agent puppet-3.0.0]# puppet agent --test --server master.test.com
Info: Retrieving plugin
Error: /File[/var/lib/puppet/lib]: Could not evaluate: Could not retrieve information from environment production source(s) puppet://master.test.com/plugins
Info: Caching catalog for agent.test.com
Info: Applying configuration version '1480151413'
/Stage[main]//File[/tmp/temp1.txt]/ensure: defined content as '{md5}e59ff97941044f85df5297e1c302d260'
Finished catalog run in 0.04 seconds
[root@agent puppet-3.0.0]# cat /tmp/temp1.txt
Hello World
[root@agent puppet-3.0.0]#
上面錯(cuò)誤的信息原因:
Error: /File[/var/lib/puppet/lib]: Could not evaluate: Could not retrieve information from environment production source(s) puppet://master.test.com/plugins
不影響: 原因未知
【puppet清楚證書】
master端:
[root@shzr-vctr001 user]# puppet cert --clean shzr-vapp015.a.pa.com
Notice: Revoked certificate with serial 14
Notice: Removing file Puppet::SSL::Certificate shzr-vapp015.a.pa.com at '/var/lib/puppet/ssl/ca/signed/shzr-vapp015.a.pa.com.pem'
Notice: Removing file Puppet::SSL::Certificate shzr-vapp015.a.pa.com at '/var/lib/puppet/ssl/certs/shzr-vapp015.a.pa.com.pem'
client端:
\rm -r /var/lib/puppet/ssl/
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。