- Puppet service 资源
- 作用:
- ①.管理服务的状态;
- ②.服务能够在配置文件更改的情况下自动重启。
- 格式:
-
- service {"title": #服务名, 通常就是在/etc/init.d/目录下的名字
- ensure => {running|stopped}, #当前service的状态
- enable => {true|false}, #service是否开机启动,chkconfig
- [status|start|stop|restart] => "cmd", #指定要执行的完整命令,当且仅当,启动脚本不在/etc/init.d/下的
- path => "目录", #启动脚本的搜索路径,可以用冒号分割多个路径,或者用数组指定
- hasrestart => {true|false}, #是否支持restart参数,如果不支持,就用stop和start实现restart效果.
- hasstatus => {true|false}, #是从命令行status查询还是从进程表(有没有该进程)中,查询service的状态
- provider => base|daemontools|init; #默认为init
- }
-
- 实例:
- #vsftpd,启动且开机自起
- vi /etc/puppet/manifest/test.pp
- service { "vsftpd":
- ensure => running,
- enable => true,
- }
-
- #检查
- # /etc/init.d/vsftpd status
- vsftpd is stopped
- # chkconfig --list vsftpd
- vsftpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
- #
- # puppet agent --test -v --server master.perofu.com
- info: Caching catalog for client.perofu.com
- info: Applying configuration version '1395069819'
- notice: /Stage[main]//Service[vsftpd]/ensure: ensure changed 'stopped' to 'running'
- notice: Finished catalog run in 0.38 seconds
- #
- # /etc/init.d/vsftpd status
- vsftpd (pid 20118) is running...
- # chkconfig --list vsftpd
- vsftpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
-
- #源码
- service { "httpd":
- ensure => running,
- restart => "/usr/local/apache2/bin/apachectl restart",
- hasrestart => "true",
- }
- 至此,puppet的service资源就结束了,接下来的是exec资源的学习,请听下回分解!!!
复制代码
|