简单的文件配置
master端
vim /etc/puppet/manifests/site.pp ###########################内容如下 node default{ file {"/tmp/test.txt": content=>"I am test puppet "; } }
第一次需要重启Master
service puppetmaster restart
客户端请求
[root@client01 puppet]# puppet agent --test Info: Retrieving pluginfacts Info: Retrieving plugin Info: Caching catalog for client01.test.com Info: Applying configuration version '1476164638' Notice: /Stage[main]/Main/Node[default]/File[/tmp/test.txt]/ensure: defined content as '{md5}a54460ca5545fddd6250f9aab22fc857' Notice: Finished catalog run in 0.06 seconds [root@client01 puppet]# ll /tmp/ total 4 -rw-r--r-- 1 root root 17 Oct 11 13:43 test.txt -rw-------. 1 root root 0 Mar 21 2016 yum.log [root@client01 puppet]# cat /tmp/test.txt I am test puppet
查看到文件以及同步过来了
创建文件并改变用户和授权
node default{ file {"/tmp/test.txt": content=>"I am test puppet "; owner => "root" group => "puppet" mode => "0777" } }
管理组和用户:
group {"test":
gid =>999,
ensure => present,
}
user {"hmy":
name => "yf",
uid => 999,
gid => test,
managehome => true
}
默认是false
ensure => present
groups => ['puppet','xfs']
shell => "/bin/bash"
实例
user {"test1":
name => "test",
uid => 999,
gid => test,
managehome => true,
ensure => present,
groups => ['puppet'],
shell => "/bin/bash";
}
定时任务cron
cron { "ntp time":
command => "/usr/sbin/ntpdate pool.ntp.org >/dev/null 2>&1",
minute => '*/10',
hour => ['2-4'],
monthday => [2,4],
ensure => present,
}
文件同步案例:
同步master端/etc/puppet/system_conf/下的文件到agent
a修改master配置文件
[root@master01 puppet]# vim fileserver.conf [system_conf] path /etc/puppet/system_conf allow *
重启
[root@master01 puppet]# /etc/init.d/puppetmaster restart
Stopping puppetmaster: [ OK ]
Starting puppetmaster: [ OK ]
b 把需要同步的文件放到master的/etc/puppet/system_conf下
cp /etc/resolv.conf /etc/puppet/system_conf/
c 修改master端 site.pp
file {"/etc/resolv.conf":
mode => 644,
source => "puppet://master01.test.com/system_conf/resolv.conf";
}
d 客户端同步
# puppet agent --test
这个实例可以配置:
系统文件 hosts,resolv.conf,i18n,yum配置文件
脚本文件 /script/service_all_clear.sh