Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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)?

share|improve this question
    
believe you are asking about what in puppet terminology is called "subscribing". The same way in the examples ntp is restarted after being installed or updated, you can do what you want here. – Sirex Jan 8 '12 at 15:31
2  
try here: docs.puppetlabs.com/learning/ordering.html – Sirex Jan 8 '12 at 15:32
5  
Isn't it enough to just remove the package? It should be automatically stopped. – Khaled Jan 8 '12 at 17:03
    
@Khaled I'm not sure. Perhaps, but I'm rater be safe than sorry. – vpetersson Jan 9 '12 at 15:49
    
@Sirex Ordering does not help here. To stop a service you need an init script, which is usually part of the package. But you want to uninstall the package at the same time. For me it looks like it's not solvable with normal puppet means. – Slaven Rezic Nov 25 '15 at 14:23

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,
}
share|improve this answer
    
Thanks @hayalci. I think it should be the other way around though: package { 'supervisor': ensure => absent, } service { 'supervisor': ensure => stopped, enable => false, hasstatus => true, require => Package["supervisor"], } However, I still get errors, just fewer of them. – vpetersson Jan 9 '12 at 15:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.