【2】puppet笔记 - package、service、user资源
各类资源详细使用方法:http://docs.puppetlabs.com/references/latest/type.htmlpackage、service、user资源简单使用
package:
# vi pack.pp
package {
"lrzsz":
ensure=>installed;
}
ps -ef | grep yum
root 19517 191429 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/Package/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/Service/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/Service/enable (notice): enable changed 'false' to 'true'
Mon Apr 14 17:52:55 +0800 2014 Puppet (notice): Finished catalog run in 0.38 seconds
# chkconfig | grep ntpd
ntpd 0:关闭1:关闭2:关闭3:关闭4:关闭5:关闭6:关闭
ntpdate 0:关闭1:关闭2:关闭3:关闭4:关闭5:关闭6:关闭
# 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)生成。
# grub-md5-crypt
Password:输入密码
Retype password:重新输入密码
$1$DiL2g1$rhrezXC7NfsmzaLXOoee6/ 这个字符串就可以放到pp文件中(123456)
#
页:
[1]