|
各类资源详细使用方法:http://docs.puppetlabs.com/references/latest/type.html
package、service、user资源简单使用
package:
[root@pclient test]# vi pack.pp
package {
"lrzsz":
ensure=>installed;
}
ps -ef | grep yum
root 19517 19142 9 16:19 ? 00:00:09 /usr/bin/python /usr/bin/yum -d 0 -e 0 -y install lrzszMon 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)。
service:
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:关闭
常用的一般启动、停止服务或者开机启动、停止服务
user:
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]# |
|
|