歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> CentOS 6.3下Poppet功能模塊實例筆記

CentOS 6.3下Poppet功能模塊實例筆記

日期:2017/2/28 14:48:22   编辑:Linux教程

之前的文章介紹了Poppet的初始安裝配置:

傳送門:http://www.linuxidc.com/Linux/2013-05/84738.htm

今天來介紹Poppet的具體實用功能,其實我的理解就是怎麼偷懶,呵呵。

1.填充文件內容:

(server):

修改server端配置文件:

# vi /etc/puppet/manifests/site.pp

-----------------

node default{

file { "/tmp/test":

content=> "this is a test file";

}

}

-----------------

重啟puppetmaster,更新配置文件信息。

# service puppetmaster restart

(client):

重啟puppet(可不用重啟)

# service puppet restart

同步文件:

# puppetd --server server.example.com --test

------------------

warning: peer certificate won't be verified in this SSL session

info: Caching certificate for client.example.com

info: Caching certificate_revocation_list for ca

info: Caching catalog for client.example.com

info: Applying configuration version '1369124449'

notice: /Stage[main]//Node[default]/File[/tmp/test]/ensure: defined content as '{md5}100b144907af2a4786003758a0a6a563'

info: Creating state file /var/lib/puppet/state/state.yaml

notice: Finished catalog run in 0.02 seconds

------------------

查看/tmp/test文件及文件內容

# cat /tmp/test

-----------

this is a test file

-----------

2.文件分發:

通過puppet可以向被管理機上推送文件,方法是使用file類型的source屬性

1:修改/etc/puppet/fileserver.conf

2:修改/etc/puppet/manifests/site.pp

實例:要把server服務器上/root目錄下的puppet-2.6.13.tar.gz傳輸至client服務器的/tmp目錄下,文件名不變。

# vi /etc/puppet/fileserver.conf

----------------

[files]

path /root

allow 192.168.7.0/24

----------------

# vi /etc/puppet/manifests/site.pp

添加到node default{}內:

---------------

file { "/tmp/puppet-2.6.13.tar.gz":

source => "puppet://$puppetserver/files/puppet-2.6.13.tar.gz",

}

---------------

重啟poppetmaster服務

# service poppetmaster restart

(client):

執行更新命令

# puppetd --test --server server.example.com

此處“$puppetserver”是puppet Server端的名稱,即本機hostname,網上教程都是在hosts裡指定,生產環境下建議用內部的DNS上作解析

Copyright © Linux教程網 All Rights Reserved