溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

面向云管理工具puppet的部署和文件傳輸測試

發(fā)布時(shí)間:2020-03-27 11:27:27 來源:網(wǎng)絡(luò) 閱讀:5040 作者:凌激冰 欄目:編程語言

面向云管理工具puppet的部署和測試

 系統(tǒng)環(huán)境:

面向云管理工具puppet的部署和文件傳輸測試

  1. [root@rhel6u3-102 puppet]# uname -r 

  2. 2.6.32-279.el6.x86_64 

  3. [root@rhel6u3-102 puppet]# cat /etc/redhat-release  

  4. Red Hat Enterprise Linux Server release 6.3 (Santiago) 

一、前期準(zhǔn)備工作
1、主機(jī)名能夠互相解析(DNS上或者h(yuǎn)osts文件中能夠相互解析)
puppet master(rhel6u3-102.rsyslog.org 192.168.100.102)
puppet agent節(jié)點(diǎn)(rhel6u3-207.rsyslog.org 192.168.100.207)
2、系統(tǒng)時(shí)間必須一致
注意:本地已經(jīng)下載好了安裝包,并且配置好了yum源
二、安裝puppet
服務(wù)器端master
  1. yum install ruby ruby-libs ruby-shadow compat-readline5 libselinux-ruby augeas-libs 

  2. rpm -ivh facter-1.6.6-1.el6.x86_64.rpm puppet-2.6.18-3.el6.noarch.rpm puppet-server-2.6.18-3.el6.noarch.rpm ruby-augeas-0.4.1-1.el6.x86_64.rpm ruby-mysql-2.8.2-1.el6.x86_64.rpm ruby-shadow-1.4.1-13.el6.x86_64.rpm 

客戶端節(jié)點(diǎn)slave(無需puttet-master)
  1. yum install ruby ruby-libs ruby-shadow compat-readline5 libselinux-ruby augeas-libs 

  2. rpm -ivh facter-1.6.6-1.el6.x86_64.rpm puppet-2.6.18-3.el6.noarch.rpm  ruby-augeas-0.4.1-1.el6.x86_64.rpm ruby-mysql-2.8.2-1.el6.x86_64.rpm ruby-shadow-1.4.1-13.el6.x86_64.rpm 

三、初始化puppet master(rhel6u3-102.rsyslog.org)
配置文件路徑/etc/puppet/
查看配置文件方法:
  1. sed -e '/#/d' -e '/^$/d' puppet.conf 

可通過以下命令生成一個(gè)更為詳細(xì)的配置文件
  1. #puppetmasterd --genconfig >puppet.conf.out  


  1. [root@rhel6u3-102 puppet]# sed -e '/#/d' -e '/^$/d' puppet.conf.out  

  2. [master] 

  3. ssldir = /var/lib/puppet/ssl 

  4. factdest = /var/lib/puppet/facts/ 

  5. privatekeydir = /var/lib/puppet/ssl/private_keys 

  6. rundir = /var/run/puppet 

  7. hostcsr = /var/lib/puppet/ssl/csr_rhel6u3-102.rsyslog.org.pem 

  8. hostpubkey = /var/lib/puppet/ssl/public_keys/rhel6u3-102.rsyslog.org.pem 

  9. plugindest = /var/lib/puppet/lib 

  10. inventory_terminus = yaml

  11. publickeydir = /var/lib/puppet/ssl/public_keys 

  12. factsource = puppet://puppet/facts/ 

  13. privatedir = /var/lib/puppet/ssl/private 

  14. logdir = /var/log/puppet 

  15. libdir = /var/lib/puppet/lib 

  16. statedir = /var/lib/puppet/state 

  17. hostcert = /var/lib/puppet/ssl/certs/rhel6u3-102.rsyslog.org.pem 

  18. localcacert = /var/lib/puppet/ssl/certs/ca.pem 

  19. pluginsource = puppet://puppet/plugins 

  20. certdir = /var/lib/puppet/ssl/certs 

  21. factpath = /var/lib/puppet/lib/facter:/var/lib/puppet/facts 

  22. httplog = /var/log/puppet/http.log 

  23. requestdir = /var/lib/puppet/ssl/certificate_requests 

  24. passfile = /var/lib/puppet/ssl/private/password 

  25. hostprivkey = /var/lib/puppet/ssl/private_keys/rhel6u3-102.rsyslog.org.pem 

  26. hostcrl = /var/lib/puppet/ssl/crl.pem 

  27. authconfig = /etc/puppet/namespaceauth.conf 

  28. localconfig = /var/lib/puppet/state/localconfig 

  29. client_datadir = /var/lib/puppet/client_data 

  30. reportserver = puppet

  31. inventory_server = puppet

  32. ca_server = puppet

  33. lastrunreport = /var/lib/puppet/state/last_run_report.yaml 

  34. node_name_value = rhel6u3-102.rsyslog.org 

  35. statefile = /var/lib/puppet/state/state.yaml 

  36. clientbucketdir = /var/lib/puppet/clientbucket 

  37. classfile = /var/lib/puppet/state/classes.txt 

  38. report_server = puppet

  39. inventory_port = 8140

  40. ca_port = 8140

  41. puppetdlockfile = /var/lib/puppet/state/puppetdlock 

  42. splaylimit = 1800

  43. clientyamldir = /var/lib/puppet/client_yaml 

  44. puppetdlog = /var/log/puppet/puppetd.log 

  45. report_port = 8140

  46. lastrunfile = /var/lib/puppet/state/last_run_summary.yaml 

  47. graphdir = /var/lib/puppet/state/graphs 

  48. capub = /var/lib/puppet/ssl/ca/ca_pub.pem 

  49. csrdir = /var/lib/puppet/ssl/ca/requests 

  50. autosign = /etc/puppet/autosign.conf 

  51. cert_inventory = /var/lib/puppet/ssl/ca/inventory.txt 

  52. cacert = /var/lib/puppet/ssl/ca/ca_crt.pem 

  53. cacrl = /var/lib/puppet/ssl/ca/ca_crl.pem 

  54. signeddir = /var/lib/puppet/ssl/ca/signed 

  55. serial = /var/lib/puppet/ssl/ca/serial 

  56. ca_name = Puppet CA: rhel6u3-102.rsyslog.org 

  57. cakey = /var/lib/puppet/ssl/ca/ca_key.pem 

  58. caprivatedir = /var/lib/puppet/ssl/ca/private 

  59. capass = /var/lib/puppet/ssl/ca/private/ca.pass 

  60. cadir = /var/lib/puppet/ssl/ca 

  61. railslog = /var/log/puppet/rails.log 

  62. dblocation = /var/lib/puppet/state/clientconfigs.sqlite3 

  63. rest_authconfig = /etc/puppet/auth.conf 

  64. modulepath = /etc/puppet/modules:/usr/share/puppet/modules 

  65. yamldir = /var/lib/puppet/yaml 

  66. reportdir = /var/lib/puppet/reports 

  67. masterlog = /var/log/puppet/puppetmaster.log 

  68. server_datadir = /var/lib/puppet/server_data 

  69. config = /etc/puppet/puppet.conf 

  70. pidfile = /var/run/puppet/master.pid 

  71. manifestdir = /etc/puppet/manifests 

  72. masterhttplog = /var/log/puppet/masterhttp.log 

  73. bucketdir = /var/lib/puppet/bucket 

  74. fileserverconfig = /etc/puppet/fileserver.conf 

  75. manifest = /etc/puppet/manifests/site.pp 

  76. templatedir = /var/lib/puppet/templates 

  77. tagmap = /etc/puppet/tagmail.conf 

  78. archive_file_server = puppet

  79. rrddir = /var/lib/puppet/rrd 

  80. rrdinterval = 1800

1、修改主配置文件 puppet.conf 插入master字段
  1. vim /etc/puppet/puppet.conf  

  2. [master] 

  3. certname=rhel6u3-102.rsyslog.org \\設(shè)置puppet認(rèn)證服務(wù)器主機(jī)名 

2、創(chuàng)建節(jié)點(diǎn)全局配置文件site.pp,文件存在,服務(wù)才能夠啟動(dòng)
  1. # touch /etc/puppet/manifests/site.pp 

3、啟動(dòng)puppetmaster服務(wù)
  1. # /etc/rc.d/init.d/puppetmaster start 

第一次測試或者調(diào)試的時(shí)候可以考慮以下方法
  1. #puppet master --verbose --no-daemonize --debug  

四、配置agent節(jié)點(diǎn)(rhel6u3-207.rsyslog.org)
1、配置第一個(gè)agent節(jié)點(diǎn),在main標(biāo)簽中添加master的主機(jī)名
  1. vim /etc/puppet/puppet.conf  

  2. [main] 

  3. server=rhel6u3-102.rsyslog.org 

2、啟動(dòng)agent服務(wù)
  1. # /etc/rc.d/init.d/puppet start 

第一次測試或者調(diào)試的時(shí)候可以考慮以下方法
  1. # puppet agent --verbose –no-daemonize 

五、配置puppet master 將搜索到的新節(jié)點(diǎn)進(jìn)行注冊(cè)
  1. #puppet cert --list \\查看等待注冊(cè)的節(jié)點(diǎn) 

  2. #puppet cert --sign rhel6u3-207.rsyslog.org \\注冊(cè)指定節(jié)點(diǎn) 

  3. # puppet cert --sign all \\注冊(cè)所有等待注冊(cè)的節(jié)點(diǎn) 

六、在puppet master創(chuàng)建一個(gè)puppet配置
1、創(chuàng)建第一個(gè)puppet配置
1)定義全局配置 site.pp文件,并創(chuàng)建import的目錄
  1. # vim /etc/puppet/manifests/site.pp  

  2. $puppetserver = 'rhel6u3-102.rsyslog.org'

  3. import 'nodes/*' 

  4. #mkdir /etc/puppet/manifests/nodes -p 

2)配置節(jié)點(diǎn)nodes.pp
  1. # vim /etc/puppet/manifests/nodes/nodes.pp 

  2. node 'rhel6u3-207.rsyslog.org'{ 

  3.         include myfile 

  4.         package { 'vim-enhanced': ensure => present } 

  5. #node /^rhel6u3-\d+\.rsyslog.org'{ 

  6. #       include myfile 

  7. #} 

2、創(chuàng)建第一個(gè)puppet模塊
1)創(chuàng)建模塊搜索路徑
  1. vim /etc/puppet/puppet.conf  

  2. [main] 

  3. modulepath=/etc/puppet/modules:/var/lib/puppet/modules:/usr/local/lib/puppet/modules 

2)創(chuàng)建模塊目錄結(jié)構(gòu)
  1. # mkdir /etc/puppet/modules -p 

  2. #mkdir -vp /etc/puppet/modules/myfile/{files,templates,manifests} 

  3. manifests目錄存放模塊配置文件,files目錄存放模塊包含的文件,templates目錄存 

  4. 放模塊中的模板 

3)創(chuàng)建模塊核心配置文件init.pp
  1. vim /etc/puppet/modules/myfile/manifests/init.pp 

  2. class myfile { 

  3.         package{ setup: 

  4. ensure => present, 

  5.         } 

  6.         file{ "/etc/myfile": 

  7. owner => "root", 

  8. group => "root", 

  9. mode => 644, 

  10. source => "puppet://$puppetserver/modules/myfile/files/etc/myfile", 

  11. require => Package["setup"], 

  12.         } 

配置基本結(jié)束,實(shí)現(xiàn)的結(jié)果如下:
1. 檢查setup軟件包是否安裝,如未安裝將安裝它
2. 下載“Puppet Master”上的myfile文件放置到/etc目錄下
4)創(chuàng)建同步的測試文件
  1. # mkdir /etc/puppet/modules/myfile/files/etc -p 

  2. #echo "Hello Puppet" >/etc/puppet/modules/myfile/files/etc/myfile 

5)客戶端測試
  1. [root@rhel6u3-207 puppet]# cat /etc/myfile  

  2. Hello Puppet 

**客戶端通過以下方式啟動(dòng),然后我們使用前臺(tái)方式運(yùn)行并監(jiān)控它,我們?cè)诶锸褂靡粋€(gè)puppet參數(shù)—noop, 它代表我們只測試,并不真的運(yùn)行并修改節(jié)點(diǎn)上的文件,--onetime參數(shù)是只執(zhí)行一次然后退出的意思。
  1. #puppet agent --server=rhel6u3-102.rsyslog.org  --no-daemonize --verbose 

  2. --noop --onetime 

  3. # puppet agent --server=rhel6u3-102.rsyslog.org --no-daemonize --verbose --noop --onetime 

  4. info: Caching catalog for rhel6u3-207.rsyslog.org 

  5. info: Applying configuration version '1366705990' 

  6. notice: Finished catalog run in 0.20 seconds 

6)默認(rèn)客戶端同步時(shí)間為30分鐘,可以設(shè)置為5秒測試效果
  1. vim /etc/puppet/puppet.conf  添加以下字段 

  2. [agent] 

  3. runinterval=5

測試方法:
服務(wù)器端 
  1. # date >>/etc/puppet/modules/myfile/files/etc/myfile  

客戶端
  1. cat /etc/myfile  

  2. Hello Puppet 

  3. 2013年 04月 23日 星期二 16:52:58 CST 

puppet支持的全部資源類型及其屬性
http://docs.puppetlabs.com/references/stable/type.html
獲取包的方法:
使用PuppetLabs公司的YUM安裝源的準(zhǔn)備方法:
# rpm -ivh http://yum.puppetlabs.com/el/6/products/i386/puppetlabs-release-6-6.noarch.rpm
使用RedHat EPEL的YUM源的準(zhǔn)備方法:
# rpm -ivh http://mirrors.ustc.edu.cn/fedora/epel/6/i386/epel-release-6-8.noarch.rpm
向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請(qǐng)聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI