puppet service not stopping service
notice ("This should be echoed")
service { "iptables":
ensure => "stopped",
}
This does not stop iptables, I am not sure why. service iptables stop
works fine. Puppet 2.6.17 on CentOS 6.3.
UPDATE:
/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!")
}
}
It is different for iptables since there is no daemon, it is not like for crond daemon for example. Service type will look in the process table for a process name "iptables" and if it is not there it will assume it is stopped. Add 'hasstatus => true' and it will work. EDITED: status => "true", worked this usually supplies for type service manually, this command must return 0 if the service is running and a nonzero value otherwise.
notice ("This should be echoed")
service { "iptables":
ensure => "stopped",
hasstatus => "true",
status => "true",
}