3.修改文件属性:
实例:把/tmp/puppet-2.6.13.tar.gz文件的权限改为puppet用户,并设置权限为777。
(server):
# vi /etc/puppet/manifests/site.pp
在source后添加:
---------------
file { "/tmp/puppet-2.6.13.tar.gz":
source => "puppet://$puppetserver/files/puppet-2.6.13.tar.gz",
owner => "puppet",
group => "puppet",
mode => 777,
}
--------------
重启poppetmaster服务
# service poppetmaster restart
(client):
执行更新命令
# puppetd --test --server server.example.com
4.执行SHELL命令或shell脚本:
实例:通过puppet分发执行shell脚本,在客户端的/tmp目录下执行test.sh脚本,该脚本实现在本目录创建一个testfile文件。
(server):
首先创建一个shell脚本test.sh,并保存在/etc/puppet/fileserver.conf配置文件中设置的/root目录下
# cd /root
# vi test.sh
---------------
#!/bin/bash
/bin/touch /tmp/testfile
---------------
重启poppetmaster服务
# service poppetmaster restart
(client):
执行更新命令
# puppetd --test --server server.example.com
设置文件分发和权限分配:
# vi /etc/puppet/manifests/site.pp
添加到node default{}内:
----------------
file { "/tmp/test.sh":
source => "puppet://$puppetserver/files/test.sh",
owner => "puppet",
group => "puppet",
mode => 755,
}
exec { "exec-mkdir":
cwd => "/tmp",
command => "sh /tmp/test.sh",
user => "puppet",
path => "/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin",
}
----------------
重启poppetmaster服务
# service poppetmaster restart
(client):
执行更新命令
# puppetd --test --server server.example.com
# ll /tmp
----------------------
.....
-rw-r--r-- 1 puppet root 0 5月 22 09:28 testfile
-rwxr-xr-x 1 puppet puppet 37 5月 22 09:28 test.sh
----------------------