各种资源详细使用方法:http://docs.puppetlabs.com/references/latest/type.htmlhtml
package、service、user资源简单使用python
package:shell
[root@pclient test]# vi pack.pp package { "lrzsz": ensure=>installed; }
ps -ef | grep yumbash
root 19517 19142 9 16:19 ? 00:00:09 /usr/bin/python /usr/bin/yum -d 0 -e 0 -y install lrzsz
Mon Apr 14 16:19:38 +0800 2014 Puppet (notice): Compiled catalog for pclient.onepc.com in environment production in 0.32 seconds Mon Apr 14 16:21:24 +0800 2014 /Stage[main]/Main/Package[lrzsz]/ensure (notice): created Mon Apr 14 16:21:24 +0800 2014 Puppet (notice): Finished catalog run in 105.42 seconds
从上面能够看到,puppet会调用yum进行安装package名。因此要使用package资源,须要机器能够连网,或者有局域网yum源(须要配置repo)。ide
service:ui
service { "ntpd": ensure=>running; } ~
Mon Apr 14 17:49:05 +0800 2014 Puppet (notice): Compiled catalog for pclient.onepc.com in environment production in 0.21 seconds Mon Apr 14 17:49:06 +0800 2014 /Stage[main]/Main/Service[ntpd]/ensure (notice): ensure changed 'stopped' to 'running' Mon Apr 14 17:49:06 +0800 2014 Puppet (notice): Finished catalog run in 0.36 seconds
service { "ntpd": ensure=>running, enable=>true; }
Mon Apr 14 17:52:54 +0800 2014 Puppet (notice): Compiled catalog for pclient.onepc.com in environment production in 0.11 seconds Mon Apr 14 17:52:55 +0800 2014 /Stage[main]/Main/Service[ntpd]/enable (notice): enable changed 'false' to 'true' Mon Apr 14 17:52:55 +0800 2014 Puppet (notice): Finished catalog run in 0.38 seconds
[root@pclient file]# chkconfig | grep ntpd ntpd 0:关闭 1:关闭 2:关闭 3:关闭 4:关闭 5:关闭 6:关闭 ntpdate 0:关闭 1:关闭 2:关闭 3:关闭 4:关闭 5:关闭 6:关闭 [root@pclient file]# chkconfig | grep ntpd ntpd 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭 ntpdate 0:关闭 1:关闭 2:关闭 3:关闭 4:关闭 5:关闭 6:关闭
经常使用的通常启动、中止服务或者开机启动、中止服务htm
user:md5
user { "hxw": name=>"hxw", ensure=>present, shell=>"/bin/bash", uid=>1688, home=>"/home/hxw", managehome=>true, password=>'$1$DiL2g1$rhrezXC7NfsmzaLXOoee6/'; }
password使用grub-md5-crypt (grub)生成。资源
[root@pclient home]# grub-md5-crypt Password: 输入密码 Retype password: 从新输入密码 $1$DiL2g1$rhrezXC7NfsmzaLXOoee6/ 这个字符串就能够放到pp文件中(123456) [root@pclient home]#