各種資源詳細使用方法: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]#