之前的文章介绍了Poppet的初始安装配置:
今天来介绍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上作解析