On Fri, Jul 03, 2015 at 02:10:55PM +0100, R.I.Pienaar wrote:
> hello,
>
> I am looking for a way to influence run order without also doing dependencies.
>
> I have a case where I am removing a bit of software from my system and so as is
> typical things need to be done in a different order from creation, crucially I
> also do not really care if removal fails. It should just try to remove everything
> independent of each other - but at least in a given order so there's some chance
> of it working.
I couldn't say about doing things without dependencies, but for uninstalling stuff I have wrapped everything in a giant if/then or had two different classes doing different things.
class c1 ($un = false) {
if str2bool($un) {
service { 'mys': ensure => stopped, enable => false }
package { 'myp': ensure => absent, }
}
else {
package { 'myp': }
service { 'mys': ensure => running, enable => true, require => Package['myp'] }
}
}
Once managing the service resource fails on every host (due to a lack of init script from package removal) I amend the manifests. Filthy but it works.
> There seems to be no way to influence order which does not also imply a requirement
> and so today the only way this is achieved is by invoking puppet 3 times with 3
> different manifest files which seems horrible but that's the only way I can find
> to achieve this as well.
If you don't care about the service maybe just kill it?
class c2 {
exec {'k': command => 'killall -9 mys || true', path => ['/bin', '/usr/bin'], }
package { 'myp': ensure => absent, require => Exec['k'], }
}
(Using true because an exec fails on a non-zero exit status iirc.)
> I tried:
>
> exec{"false": before => Exec["true"]}
> exec{"true": }
>
> This fails because before implies a requirement.
>
> Surprisingly this also implies a requirement:
>
> exec{"false": notify => Exec["true"]
> exec{"true": }
>
> Here the true exec is skipped when false exec fails, I really did not expect
> this to be the case
>
> ---
> R.I.Pienaar
>
> --
> You received this message because you are subscribed to the Google Groups "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
puppet-users...@googlegroups.com.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-users/886907918.98844.1435929055488.JavaMail.zimbra%40devco.net.
> For more options, visit
https://groups.google.com/d/optout.