Puppet: Package removal and ensure stopped
I'm pretty new to Puppet, but I really like it thus far. Right now I'm currently setting it up to automate a small architecture.
I have one problem though -- I want to remove a package, and ensure that it is stopped. To accomplish this, I have the following entry in my manifest:
package { 'supervisor':
ensure => absent,
}
service { 'supervisor':
ensure => stopped,
enable => false,
hasstatus => true,
}
The problem with this is that once the manifest been applied to the node once, I get the following error upon next run:
debug: Service[supervisor](provider=debian): Could not find supervisor in /etc/init.d
debug: Service[supervisor](provider=debian): Could not find supervisor.sh in /etc/init.d
err: /Stage[main]/Screenly_core/Service[supervisor]: Could not evaluate: Could not find init script for 'supervisor'
Is there any way to do some kind of conditional statement, such that the stop-procedure only gets executed if the package was indeed present (and then run prior to the package removal)?
On debian based systems (and I assume also on rpm systems) removing a package stops its services before deleting files (prerm phase in deb packages).
But what you ask can be achieved by inserting a dependency with 'require'
package { 'supervisor':
ensure => absent,
require => Service["supervisor"],
}
service { 'supervisor':
ensure => stopped,
enable => false,
hasstatus => true,
}