溫馨提示×

溫馨提示×

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

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

使用puppet實現(xiàn)自動化運維

發(fā)布時間:2020-04-14 00:59:29 來源:網絡 閱讀:4212 作者:末班車New 欄目:建站服務器

使用puppet實現(xiàn)自動化運維

 

服務概述:

1、什么是puppet

puppet是一個為實現(xiàn)數(shù)據中心自動化管理而設計的配置管理軟件。是一種Linux、Unix平臺的集中配置管理系統(tǒng),使用ruby語言,可管理配置文件、用戶、cron任務、軟件包、系統(tǒng)服務等。puppet把這些系統(tǒng)實體稱之為資源,puppet的設計目標是簡化對這些資源的管理以及妥善處理資源間的依賴關系。

2、Puppet的工作模式

Puppet是一個C/S架構的配置管理工具,在中央服務器上安裝puppet-server軟件包(被稱作Puppetmaster)。在需要管理的目標主機上安裝puppet客戶端軟件(被稱作PuppetClient)。當客戶端連接上Puppetmaster后,定義在Puppetmaster上的配置文件會被編譯,然后在客戶端上運行。每個客戶端默認每半個小時和服務器進行一次通信,確認配置信息的更新情況。如果有新的配置信息或者配置信息已經改變,配置將會被重新編譯并發(fā)布到各客戶端執(zhí)行。也可以在服務器上主動觸發(fā)一個配置信息的更新,強制各客戶端進行配置。如果客戶端的配置信息被改變了,它可以從服務器獲得原始配置進行校正。puppet的服務器端保存著所有的對客戶端服務器的配置代碼,在puppet里面叫做manifest(清單). manifest(清單)存放在puppetmaster 服務端。 puppet客戶端下載manifest之后,可以根據manifest對服務器進行配置,例如軟件包管理,用戶管理和文件管理等等。  

端口: 8140

3、運行原理

使用puppet實現(xiàn)自動化運維   

1客戶端puppetd調用facter,facter會探測出這臺主機的一些變量如主機名、內存大小、IP地址等。然后puppetd把這些信息發(fā)送到服務器端。  

2服務器端的puppetmaster檢測到客戶端的主機名,然后會到manifest里面對應的node配置,然后對這段內容進行解析,facter送過來的信息可以作為變量進行處理的,node牽涉到的代碼才解析,其它的代碼不解析,解析分幾個過程:語法檢查、然后會生成一個中間的偽代碼,然后再把偽代碼發(fā)給客戶機。  

3客戶端接收到偽代碼之后就會執(zhí)行,客戶端再把執(zhí)行結果發(fā)送給服務器。

4-服務器再把客戶端的執(zhí)行結果寫入日志。  

4、注意:

1為了保證安全: 安裝openssl ,openssl-devel, client和server 通信基于ssl和證書通信。 只有經過puppetmaster server認證的puppet client 才可以puppetmaster server通信。 CA證書。

2默認30分鐘, client會向服務器同步一次配置文件。

3基于ruby腳本寫的。 安裝ruby開發(fā)環(huán)境。

 

對應的軟件:

軟件名

作用

facter-1.6.7.tar.gz

探測服務器上一些信息

puppet-2.7.13.tar.gz

puppet這個軟件包,包括了puppetmaster服務器軟件和puppetd客戶端。

一:實驗目標

實戰(zhàn):配置Puppet服務器 

實戰(zhàn):Puppet自動化運維5個實戰(zhàn)案例 

二:實驗環(huán)境

facter-1.6.7.tar.gz

puppet-2.7.13.tar.gz

服務端:xuegod63  IP:192.168.1.63

客戶端:xuegod64  IP:192.168.1.64

三:實驗代碼

搭建puppet服務器和puppet客戶端準備工作:

Puppet 要求所有機器有完整的域名(FQDN)。

配好: 主機名 保持兩臺服務器時間同步,只有時間同步了,CA認證才可以通過,同時要關閉iptables和selinux。 

以下操作在xueogd63和xuegod64上都操作: Puppet 要求所有機器有完整的域名(FQDN)。

 

1、配置xuegod63和xuegod64環(huán)境

1)主機名同步 

[root@xuegod63 ~]# cat /etc/hosts

192.168.1.63 xuegod63.cn

192.168.1.64 xuegod64.cn

[root@xuegod63 ~]# scp /etc/hosts 192.168.1.64:/etc/ #hosts配置文件復制到xuegod64

2)保持兩臺服務器時間同步

[root@xuegod63 ~]# cat /etc/ntp.conf

server 0.rhel.pool.ntp.org

server 1.rhel.pool.ntp.org

server 2.rhel.pool.ntp.org

[root@xuegod63 ~]# ntpdate 0.rhel.pool.ntp.org #

15 Dec 20:36:57 ntpdate[3652]: step time server 202.112.31.197 offset 31.527473 sec

[root@xuegod63 ~]# date

Mon Dec 15 20:37:14 CST 2014

[root@xuegod63 64 ~]# crontab -e

*/5 * * * * /usr/sbin/ntpdate 0.rhel.pool.ntp.org &

3)保持域名一致

[root@xuegod63 ~]# cat /etc/sysconfig/network

NETWORKING=yes

HOSTNAME=xuegod63.cn

[root@xuegod64 ~]# cat /etc/sysconfig/network

NETWORKING=yes

HOSTNAME=xuegod64.cn 

2、xuegod63安裝puppet服務端

上傳軟件包:

facter-1.6.7.tar.gz #探測服務器上一些信息

puppet-2.7.13.tar.gz # puppet包括,puppetmaster服務器軟件和puppetd客戶端軟件包

 

1)安裝ruby openssl openssl-devel: 

[root@xuegod63 ~]# yum install openssl openssl-devel

[root@xuegod63 ~]# yum install ruby -y

注:xuegod63和xuegod64上都安裝facter-1.6.7.tar.gz和puppet-2.7.13.tar.gz。區(qū)別那一臺主機是服務端和客戶端,在于每臺機器上生成服務器腳本不一樣。

2)安裝:facter-1.6.7.tar.gz

[root@xuegod63 ~]# tar zxvf facter-1.6.7.tar.gz

[root@xuegod63 ~]# cd facter-1.6.7

[root@xuegod63 facter-1.6.7]# ruby install.rb

3)安裝:puppet-2.7.13.tar.gz

[root@xuegod63 ~]# tar zxvf puppet-2.7.13.tar.gz

[root@xuegod63 ~]# cd puppet-2.7.13

[root@xuegod63 puppet-2.7.13]# ruby install.rb

4)xuegod63復制配置文件:

[root@xuegod63 puppet-2.7.13]# cp conf/redhat/fileserver.conf  /etc/puppet/

[root@xuegod63 puppet-2.7.13]# cp conf/redhat/puppet.conf  /etc/puppet/

[root@xuegod63 puppet-2.7.13]# mkdir /etc/puppet/manifests

[root@xuegod63 puppet-2.7.13]# cd /etc/puppet/

[root@xuegod63 puppet]# ls

auth.conf   fileserver.conf   manifests   puppet.conf

參數(shù)說明: 

// auth.conf --> puppet serverclient訪問的ACL配置文件

// fileserver.conf --> puppet server 作為文件服務器的ACL配置文件

// manifests --> Puppet腳本主文件目錄,至少需要包含site.pp文件,site.pppuppet主文件(入口文件)。所有要在服務器上執(zhí)行的操作都寫在這種.pp結尾的文件中。

// puppet.conf --> Puppet服務器配置文件

5)設置開機啟動腳本:

[root@xuegod63 puppet-2.7.13]# cp conf/redhat/server.init /etc/init.d/puppetmaster

[root@xuegod63 puppet-2.7.13]# chmod +x !$

chmod +x /etc/init.d/puppetmaster

[root@xuegod63 puppet-2.7.13]# chkconfig puppetmaster on

[root@xuegod63 puppet-2.7.13]# chkconfig --list puppetmaster

puppetmaster 0:off 1:off 2:on 3:on 4:on 5:on 6:off

6)生成puppet用戶:  

[root@xuegod63 puppet-2.7.13]# grep puppet /etc/passwd #前期查,是沒有puppet這個用戶

[root@xuegod63 puppet-2.7.13]# chmod +x /etc/init.d/puppetmaster

[root@xuegod63 puppet-2.7.13]# puppetmasterd --mkusers  #生成一下用戶

[root@xuegod63 puppet-2.7.13]# grep puppet /etc/passwd #查看用戶

puppet:x:500:500::/home/puppet:/bin/bash

7)啟動服務

[root@xuegod63 puppet-2.7.13]# /etc/init.d/puppetmaster start

Starting puppetmaster:

[root@xuegod63 puppet-2.7.13]# netstat -antup | grep 8140

tcp 0 0 0.0.0.0:8140 0.0.0.0:* LISTEN 4750/ruby 

[root@xuegod63 puppet-2.7.13]# lsof -i :8140

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME

puppetmas 4750 puppet 7u IPv4 28000 0t0 TCP *:8140 (LISTEN)

3、安裝客戶端: xuegod64.cn

1)安裝ruby openssl openssl-devel:

[root@xuegod63 ~]# scp facter-1.6.7.tar.gz puppet-2.7.13.tar.gz 192.168.1.64:/root

[root@xuegod64 ~]# yum install openssl openssl-devel

[root@xuegod64 ~]# yum install ruby -y

2)安裝:facter-1.6.7.tar.gz

[root@xuegod64 ~]# tar zxvf facter-1.6.7.tar.gz

[root@xuegod64 ~]# cd facter-1.6.7

[root@xuegod64 facter-1.6.7]# ruby install.rb

3)安裝:puppet

[root@xuegod64 ~]# tar zxvf puppet-2.7.13.tar.gz

[root@xuegod64 ~]# cd puppet-2.7.13

[root@xuegod64 puppet-2.7.13]# ruby install.rb

4)復制配置文件:

[root@xuegod64 puppet-2.7.13]# cp conf/namespaceauth.conf  /etc/puppet/

[root@xuegod64 puppet-2.7.13]# cp conf/redhat/puppet.conf  /etc/puppet/

5)設置開機啟動腳本:

[root@xuegod64 puppet-2.7.13]# cp conf/redhat/client.init  /etc/init.d/puppet

[root@xuegod64 puppet-2.7.13]# chmod +x /etc/init.d/puppet

[root@xuegod64 puppet-2.7.13]# chkconfig puppet on

6)配置xuegod64 puppet配置文件:指定puppetmaster 主機名 和 客戶端證書名 

[root@xuegod64 puppet-2.7.13]# vim /etc/puppet/puppet.conf # 插入以下紅色內容

[main]

# The Puppet log directory.

# The default value is '$vardir/log'.

logdir = /var/log/puppet

# Where Puppet PID files are kept.

# The default value is '$vardir/run'.

rundir = /var/run/puppet 

# Where SSL certificates are kept.

# The default value is '$confdir/ssl'.

ssldir = $vardir/ssl

[agent]

# The file in which puppetd stores a list of the classes

# associated with the retrieved configuratiion. Can be loaded in

# the separate ``puppet`` executable using the ``--loadclasses``

# option.

# The default value is '$confdir/classes.txt'.

classfile = $vardir/classes.txt

server = xuegod63.cn

certname = xuegod64.cn 

# Where puppetd caches the local configuration. An

# extension indicating the cache format is added automatically.

# The default value is '$confdir/localconfig'.

localconfig = $vardir/localconfig

注:

server = xuegod63.cn #指定puppetmaster 主機名

certname = xuegod64.cn #客戶端證書名

7)啟動服務

[root@xuegod64 puppet-2.7.13]# puppetmasterd --mkusers  #生成一下用戶

[root@xuegod64 puppet-2.7.13]# /etc/init.d/puppet start

[root@xuegod64 puppet-2.7.13]# netstat -antup | grep 8140

tcp 0 0 0.0.0.0:8140 0.0.0.0:* LISTEN 2829/ruby

注:發(fā)現(xiàn)服務器和客戶端都啟動8140端口

[root@xuegod63 ~]# netstat -antup | grep 8140

tcp 0 0 0.0.0.0:8140 0.0.0.0:* LISTEN 4750/ruby

4、簽名證書: 客戶端xuegod64找xuegod63簽名

1)Xuegod64 發(fā)送請求: 生成證書請求文件

[root@xuegod64 puppet-2.7.13]# puppetd --test --server xuegod63.cn

err: Could not retrieve catalog from remote server: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed. This is often because the time is out of sync on the server or client

warning: Not using cache on failed catalog

err: Could not retrieve catalog; skipping run

err: Could not send report: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed. This is often because the time is out of sync on the server or client

出了錯,解決方法: 一些文件不是證書簽名的文件

[root@xuegod64 puppet-2.7.13]# rm -rf /var/lib/puppet/ssl/*

[root@xuegod64 puppet-2.7.13]# puppetd --test --server xuegod63.cn

[root@xuegod64 puppet-2.7.13]# echo $? #返回為1,沒有問題。

1

2)xuegod63查看有哪些服務器證書請求文件

[root@xuegod63 puppet-2.7.13]# puppetca --list #查看哪些服務器申請了證書簽名。

xuegod64.cn (DB:28:A7:03:C1:B5:55:4E:68:9E:07:0E:91:4D:7C:CB)

3)對請求文件進行簽名

[root@xuegod63 puppet-2.7.13]# puppetca -s xuegod64.cn #只簽名某個客戶端。服務器端對 -a表示對所有的請求文件進行簽名,xuegod64簽名

notice: Signed certificate request for xuegod64.cn

notice: Removing file Puppet::SSL::CertificateRequest xuegod64.cn at '/var/lib/puppet/ssl/ca/requests/xuegod64.cn.pem'

[root@xuegod63 puppet-2.7.13]# puppetca -s -a # 對所有客戶端全部簽名

No waiting certificate requests to sign

[root@xuegod63 puppet-2.7.13]# ls  /var/lib/puppet/ssl/ca/requests/  #空的,沒有任何文件

[root@xuegod63 puppet-2.7.13]# ls  /var/lib/puppet/ssl/ca/signed/

xuegod63.cn.pem  xuegod63.pem  xuegod64.cn.pem

4)查看證書簽名, 前面有+號,表示已經簽名成功

[root@xuegod63 puppet-2.7.13]# puppetca -a --list

+ xuegod63.cn (24:49:4F:DC:0B:55:CD:50:F9:A6:D0:F9:BA:56:A1:D6) (alt names: DNS:puppet, DNS:puppet.cn, DNS:xuegod63.cn)

+ xuegod64.cn (D1:2D:D4:95:38:46:F0:B4:A8:7E:58:5D:ED:89:35:84)

服務器簽名過的證書存放位置

[root@xuegod63 puppet-2.7.13]# ls /var/lib/puppet/ssl/ca/signed/* #服務器簽名過的證書存放位置

/var/lib/puppet/ssl/ca/signed/xuegod63.cn.pem

/var/lib/puppet/ssl/ca/signed/xuegod64.cn.pem

5)xuegod64重啟服務器,獲得可用的新CA證書,并使用新的CA證書和服務器端通信:

[root@xuegod64 puppet-2.7.13]# ls /var/lib/puppet/ssl/certs/

ca.pem

[root@xuegod64 puppet-2.7.13]# /etc/init.d/puppet restart

[root@xuegod64 puppet-2.7.13]# ls /var/lib/puppet/ssl/certs/

ca.pem xuegod64.cn.pem 

#可看到證書,說明客戶端和服務器端正常通信了。 ============================================================

5、自動運維實例: 

實戰(zhàn)1,通過puppet遠程在xuegod64的/tmp目錄下自動創(chuàng)建一個文件test.txt,并寫入內容:Welconme 

方法一:

1)xuegod63服務端配置

[root@xuegod63 puppet-2.7.13]# vim /etc/puppet/manifests/site.pp

[root@xuegod63 puppet-2.7.13]# cat /etc/puppet/manifests/site.pp

node default{

file { "/tmp/test.txt":

content=> "this is a test file";

}

}

[root@xuegod63 puppet-2.7.13]# /etc/init.d/puppetmaster restart

2)測試客戶端能否自動創(chuàng)建文件

方法1 通過重啟puppet客戶端服務,來執(zhí)行腳本

[root@xuegod64 puppet-2.7.13]# /etc/init.d/puppet restart

[root@xuegod64 puppet-2.7.13]# cat /tmp/test.txt

this is a test file

方法2:

1)同步臨時生效

[root@xuegod64 puppet-2.7.13]# puppetd --test --server xuegod63.cn

info: Caching catalog for xuegod64.cn

info: Applying configuration version '1429357828'

notice: Finished catalog run in 0.10 seconds

[root@xuegod64 puppet-2.7.13]# cat /tmp/test.txt

this is a test file

方法3:等30分鐘后自己同步。 

實例2: 文件分發(fā)。 

    要把server服務器上/opt目錄下的a.txt(apache-4.1.12.rpm)發(fā)布至client服務器的/opt目錄下,文件名不變。 注意:分發(fā)文件時,不要用/root ,會有權限問題。 

1)xuegod63配置:

[root@xuegod63 ~]# cp /etc/hosts /opt/a.txt

[root@xuegod63 ~]# vim /etc/puppet/fileserver.conf #在文件最后,追加以下內容

[files]

path /opt/

allow 192.168.1.0/24

注: [files] #名字,可以隨便寫

2)指定客戶端要執(zhí)行的操作: 

[root@xuegod63 ~]# vim /etc/puppet/manifests/site.pp

[root@xuegod63 ~]# cat /etc/puppet/manifests/site.pp #添加紅色內容

node default{

file { "/tmp/test.txt":

content=> "this is a test file";

}

file { "/opt/a.txt":

     source => "puppet://$puppetserver/files/a.txt",

                       #//xuegod63.cn//opt/a.txt

}

}

注:

file { "/opt/a.txt": #指分發(fā)到客戶端的路徑

source => "puppet://$puppetserver/files/a.txt", 中的files要和/etc/puppet/fileserver.conf中定義的名字一樣。

注:修改site.pp 文件后,服務端不需要重新啟動服務。 

3)同步臨時生效

[root@xuegod64 puppet-2.7.13]# puppetd --test --server xuegod63.cn

info: Caching catalog for xuegod64.cn

info: Applying configuration version '1418651351'

notice: /Stage[main]//Node[default]/File[/opt/a.txt]/ensure: defined content as '{md5}e7d6d91a44650a85573b0cd47f2c1647'

notice: Finished catalog run in 0.46 seconds

[root@xuegod64 puppet-2.7.13]# ls /opt/ #查看

a.txt

[root@xuegod64 puppet-2.7.13]# cat /opt/a.txt

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4

::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

192.168.1.63 xuegod63.cn

192.168.1.64 xuegod64.cn

實戰(zhàn)3: 自動修改文件屬性

1)xuegod63編寫腳本配置

[root@xuegod64 ~]# ll /opt/a.txt

-rw-r--r-- 1 root root 210 10月 22 16:31 /opt/a.txt

[root@xuegod63 ~]# cat /etc/puppet/manifests/site.pp

node default{

file { "/tmp/test":

content=> "this is a test file";

}

file { "/opt/a.txt":

source => "puppet://$puppetserver/files/a.txt",

owner => "puppet",

group => "puppet",

mode => 777,

}

}

注:需要將上一個實驗的代碼刪掉

2)同步臨時生效測試:

[root@xuegod64 puppet-2.7.13]# puppetd --test --server xuegod63.cn

info: Caching catalog for xuegod64.cn

info: Applying configuration version '1418651544'

notice: /Stage[main]//Node[default]/File[/opt/a.txt]/owner: owner changed 'root' to 'puppet'

notice: /Stage[main]//Node[default]/File[/opt/a.txt]/group: group changed 'root' to 'puppet'

notice: /Stage[main]//Node[default]/File[/opt/a.txt]/mode: mode changed '0644' to '0777'

notice: Finished catalog run in 0.30 seconds

[root@xuegod64 puppet-2.7.13]# ll /opt/a.txt

-rwxrwxrwx 1 puppet puppet 213 Dec 15 21:49 /opt/a.txt

 

4: server端讓client端自動執(zhí)行shell腳本或命令

    通過puppet分發(fā)執(zhí)行shell腳本,然后在客戶端的/opt目錄下執(zhí)行test.sh腳本,該腳本執(zhí)行后,會在/tmp目錄創(chuàng)建一個testfile文件。

1)編輯測試腳本

[root@xuegod63 ~]# vim /opt/test.sh

#!/bin/bash

/bin/touch /tmp/testfile

2)編輯腳本

[root@xuegod63 opt]#vim /etc/puppet/manifests/site.pp #寫入以下紅色標記內容

node default{

file { "/tmp/test":

content=> "this is a test file";

}

file { "/opt/a.txt":

source => "puppet://$puppetserver/files/a.txt",

owner => "puppet",

group => "puppet",

mode => 777,

}

file { "/opt/test.sh":

source => "puppet://$puppetserver/files/test.sh",

owner => "puppet",

group => "puppet",

mode => 755,

}

exec { "exec-mkdir":

cwd => "/opt",

command => "sh /opt/test.sh",

user => "puppet",

path => "/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin",

}

}

注: 不用重啟服務器的

3)同步測試:

[root@xuegod64 puppet-2.7.13]#puppetd --test --server xuegod63.cn

info: Caching catalog for xuegod64.cn

info: Applying configuration version '1418651975'

notice: /Stage[main]//Node[default]/File[/opt/test.sh]/ensure: defined content as '{md5}d68e2194d349dcc3f1990a0ce37dcf1a'

notice: /Stage[main]//Node[default]/Exec[exec-mkdir]/returns: executed successfully

notice: Finished catalog run in 1.85 seconds

[root@xuegod64 puppet-2.7.13]# ls /tmp/testfile

/tmp/testfile

[root@xuegod64 puppet-2.7.13]# ll /opt/

total 8

-rwxrwxrwx 1 puppet puppet 213 Dec 15 21:49 a.txt

-rwxr-xr-x 1 puppet puppet 37 Dec 15 21:59 test.sh

5:客戶端自動執(zhí)行服務的啟動及關閉:

   可以通過puppet對一些服務進行重啟,狀態(tài)等操作。puppet是通過service命令操作的。所以,只能針對在/etc/init.d/目錄下的服務 實例:把客戶端xuegod64的vsftpd服務關閉,并把nfs服務啟動

1)準備環(huán)境:

[root@xuegod64 ~]# rpm -ivh /mnt/Packages/vsftpd-2.2.2-6.el6_0.1.x86_64.rpm

[root@xuegod64 ~]# service vsftpd start #為了實現(xiàn)遠程關閉服務,所以這里先開著

[root@xuegod64 ~]#service nfs stop

[root@xuegod64 ~]# service vsftpd status

[root@xuegod64 ~]#service nfs status

2)配圖manifests菜單,配置客戶端如何執(zhí)行: 

[root@xuegod63 opt]# cat /etc/puppet/manifests/site.pp #添加紅色標記內容

node default{

file { "/tmp/test":

content=> "this is a test file";

}

file { "/opt/a.txt":

source => "puppet://$puppetserver/files/a.txt",

owner => "puppet",

group => "puppet",

mode => 777,

}

file { "/opt/test.sh":

source => "puppet://$puppetserver/files/test.sh",

owner => "puppet",

group => "puppet",

mode => 755,

}

exec { "exec-mkdir":

cwd => "/opt",

command => "sh /opt/test.sh",

user => "puppet",

path => "/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin",

}

service { vsftpd":

ensure => stopped;

"nfs":

ensure => running;

}

}

3)xuegod64 測試:

[root@xuegod64 ~]#puppetd --test --server xuegod63.cn

[root@xuegod64 ~]# service vsftpd status

vsftpd is stopped

[root@xuegod64 ~]# service nfs status

rpc.svcgssd is stopped

rpc.mountd (pid 8896) is running...

nfsd (pid 8893 8892 8891 8890 8889 8888 8887 8886) is running...

rpc.rquotad (pid 8880) is running...

實戰(zhàn)6:修改同步時間

    修改puppet 客戶端默認連接puppetmaster的時間 默認puppet 客戶端每隔30分鐘連接到puppetmaster, 同步一次配置文件 現(xiàn)在修改為1分鐘.同步一次。

1)修改配置文件

[root@xuegod64 ~]# cat /etc/puppet/puppet.conf #添加以下紅色標記內容

[main]

# The Puppet log directory.

# The default value is '$vardir/log'.

logdir = /var/log/puppet

# Where Puppet PID files are kept.

# The default value is '$vardir/run'.

rundir = /var/run/puppet

# Where SSL certificates are kept.

# The default value is '$confdir/ssl'.

ssldir = $vardir/ssl

[agent]

# The file in which puppetd stores a list of the classes

# associated with the retrieved configuratiion. Can be loaded in

# the separate ``puppet`` executable using the ``--loadclasses``

# option.

# The default value is '$confdir/classes.txt'.

classfile = $vardir/classes.txt

server = xuegod63.cn

certname = xuegod64.cn

runinterval = 60  #同步時間間隔默認為妙

# Where puppetd caches the local configuration. An

[root@xuegod64 ~]# /etc/init.d/puppet restart

[root@xuegod64 ~]# rm -rf /opt/*

[root@xuegod64 ~]# ls /opt/

2)測試:等待1分鐘后再查看。 

[root@xuegod64 ~]# ls /opt/ #發(fā)現(xiàn)執(zhí)行了site.pp中內容

a.txt test.sh

 


向AI問一下細節(jié)

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

AI