[Pkg-puppet-devel] Bug#529555: onlyif + unless precedence
Jayen Ashar
jayen at science.unsw.edu.au
Mon Oct 1 01:57:59 UTC 2012
On Sun, Sep 30, 2012 at 7:41 AM, Micah Anderson <micah at riseup.net> wrote:
>> http://reductivelabs.com/trac/puppet/wiki/TypeReference#exec
>> onlyif
>> If this parameter is set, then this exec will only run if the command returns 0.
>> unless
>> If this parameter is set, then this exec will run unless the command returns 0.
>>
>> So, If I specify something like:
>> exec {
>> "rm /usr/share/man/man1/x-window-manager.1.gz":
>> onlyif => "test -L /usr/share/man/man1/x-window-manager.1.gz",
>> unless => "stat -L /usr/share/man/man1/x-window-manager.1.gz",
>> path => "/usr/bin:/usr/sbin:/bin";
>> }
>>
>> Or what if x-window-manager.1.gz doesn't exist? The onlyif and unless commands both return non-zero. the unless parameter says to run the exec command, but the onlyif says not to run it.
>
> I confess, I dont understand what it is you are trying to do. Could you clarify
> a little bit?
>
> Also, have you tried this in a newer version of puppet? You reported this when
> puppet was at 0.24, and things have changed significantly since then. It would
> be good to know if this is still an issue in newer versions.
>
> thanks,
> micah
I've stopped using puppet, so I won't be trying a newer version of
puppet, but what I was trying to do was (iirc) remove that file if it
was a broken link.
The paradox created in the example was to ask what happens when
"onlyif" and "unless" conflict, that is, onlyif says _not_ to execute
rm (the onlyif command returns 1) and unless says _to_ execute rm (the
unless command returns 1). If I remember correctly, the rm was
executed despite having the onlyif check the existence of the link.
--Jayen
More information about the Pkg-puppet-devel
mailing list