puppet之service管理

本文系统Centos6.0

主机信息:

master:master.lansgg.com 192.168.182.143

client1 :client1.lansgg.com 192.168.182.142

client2: client2.lansgg.com 192.168.182.149

相关安装请看

http://lansgg.blog.51cto.com/5675165/1299604

先来看下server资源的相关属性:

1
2
3
4
5
6
7
ensure => running( true )/stopped( false ),确定是否运行
enable =>  true / false  确定是否随机启动
status,start,stop,restart=>command,(对应的命令行,也就是非标准启动)
hasrestart=>  true / false  前者是restart,后者是stop,start
hasstatus=> true , false ,前者是status查看status, false 是进程表
当不是标准启动方式的话使用status,start,stop,restart=>command,
标准的话就是running或stopped

案例1、确定client1上的httpd服务running,如果不是则start;

master:

1
2
3
4
5
6
[root@master manifests]# vim node.pp
node  'client1.lansgg.com'  {
service { "httpd" :
         ensure => running,
         }
}

client1:

224957727.jpg

案例2、将client1上的非标准服务httpd进行控制;

master:

1
2
3
4
5
6
7
[root@master manifests]# vim node.pp
node  'client1.lansgg.com'  {
service { "httpd" :
         ensure => running,
         start =>  '/root/httpd start' ,
         }
}

client1:

225743526.jpg

案例3、将服务进行重启控制

master:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
[root@master manifests]# vim node.pp
node  'client1.lansgg.com'  {
service { "httpd" :
         ensure => running,
         hasrestart =>  "true" ,
         }
}
##or
node  'client1.lansgg.com'  {
service { "httpd" :
         ensure => running,
         restart =>  '/root/httpd restart' ,
         hasrestart =>  "true" ,
         }
}
两者只是服务标准的差别

client1:

230503279.jpg

后面我们还会讲解依赖性,配置文件后,服务自动重启;

至此结束,ths



本文转自 西索oO 51CTO博客,原文链接:http://blog.51cto.com/lansgg/1300521

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值