![puppet 服务不会停止服务](https://linux22.com/image/620698/puppet%20%E6%9C%8D%E5%8A%A1%E4%B8%8D%E4%BC%9A%E5%81%9C%E6%AD%A2%E6%9C%8D%E5%8A%A1.png)
notice ("This should be echoed")
service { "iptables":
ensure => "stopped",
}
这不会停止 iptables,我不确定为什么。 service iptables stop
工作正常。CentOS 6.3 上的 Puppet 2.6.17。
更新:
/etc/puppet/manifests/nodes.pp
node 'linux-dev' {
include mycompany::install::apache::init
include mycompany::config::services::init
}
/etc/puppet/modules/mycompany/manifests/config/services/init.pp
class mycompany::config::services::init {
if ($::id == "root") {
service { 'iptables':
#name => '/sbin/iptables',
#enable => false,
#hasstatus => true,
ensure => stopped
}
notice ("IPTABLES is now being stopped...")
file { '/tmp/puppet_still_works':
ensure => 'present',
owner => root
} else {
err("Error: this manifest must be run as the root user!")
}
}
答案1
对于 iptables 来说,情况有所不同,因为没有守护进程,它与 crond 守护进程不同。服务类型将在进程表中查找进程名称“iptables”,如果不存在,它将假定它已停止。添加“hasstatus => true”即可。编辑:status =>“true”,这通常可以手动为类型服务提供,如果服务正在运行,则此命令必须返回 0,否则返回非零值。
notice ("This should be echoed")
service { "iptables":
ensure => "stopped",
hasstatus => "true",
status => "true",
}