[Puppet Users] Re: execute more commands (beginner talking)

Roy Nielsen
Wed, 21 Oct 2009 16:45:25 -0000

Use the onlyif parameter of the exec type:

exec { "touch /home/ciao:"
     cwd => "/home",
     path => "/usr/bin:/usr/sbin:/bin",
     onlyif => "/usr/bin/apt-get -q -q update"
}

Note: the onlyif parameter only works this way with the
"exec" type (works a bit differently for the augeas type)
The unless parameter only works with exec at this point.

Regards,
-Roy

Reno wrote:
> Yes I agree,
>
> for example what you will do if I want to run the touch command only
> if /usr/bin/apt-get -q -q update has run without error?
>
>  exec { subscribe-echo:
>                command     => "/usr/bin/apt-get -q -q update",
>                logoutput   => false,
>                refreshonly => true,
>                subscribe   => file["/etc/apt/sources.list"]
>        }
>
>  exec { "touch /home/ciao":
>     cwd => "/home",
>     path => "/usr/bin:/usr/sbin:/bin"
> }
>
>
>
>
> On Oct 21, 4:56 pm, Brice Figureau <brice-pup...@daysofwonder.com>
> wrote:
>> On Wed, 2009-10-21 at 08:53 -0700, Reno wrote:
>>> hi and thanks for the help
>>> I use a more simple ( to me ) but effective solution:
>>>  exec { "touch /home/ciao":
>>>     cwd => "/home",
>>>     path => "/usr/bin:/usr/sbin:/bin"
>>> }
>> You can''t guarantee this exec won''t run _before_ your
other exec if you
>> don''t add strict ordering metaparameters (require/before).
>> --
>> Brice Figureau
>> Follow the latest Puppet Community evolutions onwww.planetpuppet.org!
> >