- 論壇徽章:
- 0
|
作者: Kent Brede
最后修改: 02/25/07
本文基于: http://reductivelabs.com/trac/puppet/wiki/InstallationGuide
譯者: Ken Zhao, cn.zhaoke.com
譯文網(wǎng)址: http://blog.zhaoke.com/90.html
介紹
本文將通過循序漸進的指南, 介紹如何在一臺機器上安裝Puppet的服務(wù)器端程序和在另一臺機器上安裝Puppet客戶端程序. 然后我們使用一個簡單的測試來確認Puppet是否正常工作.
如果你不熟悉Puppet, 它是一個配置自動化工具, 你可以集中管理多個存在于您網(wǎng)絡(luò)當中的*nix操作系統(tǒng). Puppet支持集中管理系統(tǒng)的重要資源, 比如: 文件, 軟件包, 用戶, 服務(wù), cron作業(yè), 掛載文件系統(tǒng), 等. 更多完整的描述請訪問Reductive Labs網(wǎng)站.
背景
本文的安裝系統(tǒng)使用Ubuntu 6.06 LTS Server, 但是對于其它主要的Debian/Ubuntu版本只需做少量修改.
在本文撰寫其間, 當前Puppet軟件包的Ubuntu版本可以在Feisty中找到. 不推薦使用當前Debian軟件庫中的Puppet軟件包(不穩(wěn)定).
在本文當中, 我們使用example.com作為域名. 服務(wù)器的主機名為”puppet”, 服務(wù)器的IP地址為192.168.10.1. 客戶端的主機名為”pclient”, 客戶端的IP地址為192.168.10.2.
1. 網(wǎng)絡(luò)需求
如果你的網(wǎng)絡(luò)沒有建立DNS服務(wù), 請在你的服務(wù)器和客戶機端確認hosts文件包含了各自的主機名及對應的IP地址. 在這一環(huán)節(jié), 請把下面的數(shù)據(jù)添加到/etc/hosts文件, 使用您熟悉的文本編輯器, 根據(jù)你的網(wǎng)絡(luò)設(shè)置添加下面兩行.
192.168.10.1 puppet.example.com puppet
192.168.10.2 pclient.example.com pclient
服務(wù)器程序運行在8140端口上. 請確認兩臺機器之間沒有任何防火墻阻止端口8140的通信.
2. Apt安裝
我們需要的大多軟件包都可以在軟件倉庫中找到. 如果下面的幾行在”sources.list”文件中沒有被注釋, 請使用您熟悉的文本編輯器, 在服務(wù)器端找到并注釋掉.
puppet:# vim /etc/apt/sources.list
# deb http://us.archive.ubuntu.com/ubuntu/ dapper universe
# deb http://security.ubuntu.com/ubuntu dapper-security universe
我們使用了稍舊的Ubuntu版本, 從而可以通過配置apt方便從Feisty中獲得Puppet軟件包. 請根據(jù)您的操作系統(tǒng)版本修改源文件. 如果你不熟悉接下來的步驟, 請查閱Apt-Howto的3.10章節(jié).
打開”sources.list”文件, 然后添加下面兩行.
puppet:# vim /etc/apt/sources.list
deb http://us.archive.ubuntu.com/ubuntu/ feisty universe
deb http://security.ubuntu.com/ubuntu feisty-security universe
更新您的源代碼列表.
puppet:# apt-get update
**在”pclient”端執(zhí)行同樣的步驟.**
接下來, 我們對Puppet安裝相關(guān)的apt進行配置, 不要限制從Dapper軟件倉庫獲得其它的軟件包. 添加下面幾行到”preferences”文件.
puppet:# vim /etc/apt/preferences
Package: *
Pin: release a=dapper
Pin-Priority: 700
Package: facter
Pin: release a=feisty
Pin-Priority: 500
Package: puppet
Pin: release a=feisty
Pin-Priority: 500
Package: puppetmaster
Pin: release a=feisty
Pin-Priority: 500
客戶端:
pclient:# vim /etc/apt/preferences
Package: *
Pin: release a=dapper
Pin-Priority: 700
Package: facter
Pin: release a=feisty
Pin-Priority: 500
Package: puppet
Pin: release a=feisty
Pin-Priority: 500
3. 軟件需求
在準備安裝Puppet當中, 我們需要在服務(wù)器和客戶機上安裝幾個庫文件和軟件包. 另外, 如果這一步在后面執(zhí)行, 請確認軟件包的依賴性問題.
puppet:# apt-get install libopenssl-ruby rdoc irb1.8 libopenssl-ruby1.8 libreadline-ruby1.8 libruby1.8 rdoc1.8 ruby1.8
pclient:# apt-get install libopenssl-ruby rdoc irb1.8 libopenssl-ruby1.8 libreadline-ruby1.8 libruby1.8 rdoc1.8 ruby1.8
4. 客戶機端安裝
從Feisty安裝Puppet和Facter.
pclient:# apt-get -t feisty install facter puppet
5. 服務(wù)器端安裝
安裝Puppet, Facter和Puppetmaster. 后續(xù)安裝腳本將嘗試啟動服務(wù)器, 如果發(fā)生錯誤, 屏幕將來打印出來. 請不要擔心, 我們將會在第六步驟創(chuàng)建一個清單.
puppet:# apt-get -t feisty install facter puppet puppetmaster
…..
Starting puppet configuration management tool master server
Manifest /etc/puppet/manifests/site.pp must exist [fail]
6. 服務(wù)器端準備
在運行puppetmasterd之前, 服務(wù)器端(運行puppetmasterd守護進程)需要一個清單(manifest). 下面我寫了一個清單告訴puppet程序在客戶端上創(chuàng)建一個”/tmp/testfile”文件.
puppet:# vim /etc/puppet/manifests/site.pp
# Create “/tmp/testfile” if it doesn’t exist.
class test_class {
file { “/tmp/testfile”:
ensure => present,
mode => 644,
owner => root,
group => root
}
}
# tell puppet on which client to run the class
node pclient {
include test_class
}
現(xiàn)在啟動puppet服務(wù)程序.
puppet:# /etc/init.d/puppetmaster start
7. 客戶端準備
默認情況, 客戶機將通過你的網(wǎng)絡(luò)連接主機名叫做”puppet”的服務(wù)器. 如果您服務(wù)器的主機名不是”puppet”, 這樣你需要添加一個指令到puppetd的配置文件”puppetd.conf”. 為了更好的演示, 我們配置了該選項.
請使用你熟悉的文本編輯器打開”/etc/puppet/puppetd.conf”文件, 然后按下面提示添加”server=puppet.example.com”.
pclient:# vim /etc/puppet/puppetd.conf
[puppetd]
server = puppet.example.com
# Make sure all log messages are sent to the right directory
# This directory must be writable by the puppet user
logdir=/var/log/puppet
vardir=/var/lib/puppet
rundir=/var/run
8. 簽名秘鑰
為了使兩個系統(tǒng)安全的通信, 我們需要創(chuàng)建簽名的SSL證書. 你將需要登陸到客戶和服務(wù)器端執(zhí)行下面的步驟.
在客戶端上運行.
pclient:# puppetd –server puppet.example.com –waitforcert 60 –test
你將看到下面的消息.
err: No certificate; running with reduced functionality.
info: Creating a new certificate request for pclient.example.con
info: Requesting certificate
warning: peer certificate won’t be verified in this SSL session
notice: Did not receive certificate
(注:
err: 無證書; 簡化運行. [錯誤]
info: 為pclient.example.com創(chuàng)建新的證書請求 [信息]
info: 正在請求證書 [信息]
warning: 點證書將不會在此SSL會話中被驗證 [警告]
notice: 不接受證書 [注意])
接下來, 在服務(wù)器端運行下面的命令來確認客戶端正在得等待證書被簽名.
puppet:# puppetca –list
pclient.example.con
然后簽名證書
puppet:# puppetca –sign pclient.example.com
Signed pclient.example.com
如果一切, 你將在pclient客戶端看到如下消息.
info: Requesting certificate
warning: peer certificate won’t be verified in this SSL session
notice: Ignoring –listen on onetime run
info: Caching configuration at /etc/puppet/localconfig.yaml
notice: Starting configuration run
notice: //pclient/test_class/File[/tmp/testfile]/ensure: created
info: Creating state file /var/lib/puppet/state/state.yaml
notice: Finished configuration run in 0.11 seconds
(注:
info: 正在請求證書 [信息]
warning: 點證書將不會在此SSL會話中被驗證 [警告]
notice: 忽略 — 運行時監(jiān)聽 [注意]
info: 緩存配置到/etc/puppet/localconfi.yaml [信息]
notice: 開始運行配置 [注意]
notice: //pclient/test_class/File[/tmp/testfile]/ensure: 改文件被創(chuàng)建 [注意]
info: 創(chuàng)建狀態(tài)文件/var/lib/puppet/state/state.yaml [信息]
notice: 完成運行配置, 耗時0.11秒 [注意] )
9. 測試
檢查和確認文件是否已創(chuàng)建.
pclient:# ls -l /tmp/testfile
-rw-r–r– 1 root root 0 2007-02-18 18:28 /tmp/testfile
修改清單(manifest)和Puppset的文件權(quán)限模式. 修改行, “mode=>644,”為”mode=>600,”
# Create “/tmp/testfile” if it doesn’t exist.
class test_class {
file { “/tmp/testfile”:
ensure => present,
mode => 600,
owner => root,
group => root
}
}
# tell puppet on which client to run the class
node pclient {
include test_class
在客戶端上以詳細模式(verbose)和僅一次模式運行puppetd服務(wù)程序.
pclient:# puppetd -v -o
你將看到下面的消息, /tmp/testfile的文件權(quán)限將從644改為600.
notice: Ignoring –listen on onetime run
info: Config is up to date
notice: Starting configuration run
notice: //pclient/test_class/File[/tmp/testfile]/mode: mode changed ‘644′ to ‘600′
notice: Finished configuration run in 0.26 seconds
(注:
notice: 忽略 — 運行時監(jiān)聽 [注意]
info: Config配置已更新 [信息]
notice: 開始運行配置 [注意]
notice: //pclient/test_class/File[/tmp/testfile]/mode: 模式從’644′修改為’600′ [注意]
notice: 完成運行配置, 耗時0.26秒 [注意] )
然后確認工作是否正確完成.
pclient:# ls -l /tmp/testfile
-rw——- 1 root root 0 2007-02-18 18:28 /tmp/testfile
10. 結(jié)論
配置, 測試已經(jīng)完成, 你已經(jīng)成功安裝了Puppet. 下面的步驟是創(chuàng)建一個功能清單, 測試更多的選項, 然后在客戶端啟動puppetd守護程序. 默認情況, Puppetd將會每隔30分鐘自動重新啟動它的配置.
pclient:# /etc/init.d/puppet start
更多信息請訪問Reductive Labs網(wǎng)站. 如果你需要即時的幫助, 請加入Puppet Users郵件列表或者irc.freenode.net的#puppet.
原文
Configuration Automation & Centralized Management With Puppet on Ubuntu
備注
轉(zhuǎn)載請保持文章完整性, 歡迎到blog.zhaoke.com網(wǎng)站與趙珂交流.
本文來自ChinaUnix博客,如果查看原文請點:http://blog.chinaunix.net/u3/99907/showart_2161530.html |
|