Hey,

we want to check a condition before executing some commands.
If a line is existing in a list of architectures, the command should not 
run - and vice versa.
So we use grep and count the words (wc -l).

The expected behaviour: if the onlyif-command returns 0, execute. If not, 
don't.
(according to reference: 
http://docs.puppetlabs.com/references/latest/type.html#exec-attribute-onlyif
)

Running the onlyif-command separately from puppet exectution, the return 
value is as expected.
But the Exec-command is executed every time, despite the actual return 
value.
Also, running "echo 0" as well as "echo 1" as onlyif triggers an execution.

Here is the code snippet used in our manifest

exec { "hammer execution":
>         command => "hammer architecture create --name x86_64 \
>                 && hammer environment create --name cloudbox",
>         path    => "/usr/local/bin/",
>         require => [
>                         File["/var/log/foreman/hammer.log"],
>                         File["/etc/foreman/cli_config.yml"],
>                         Package["hammer_cli_foreman"],
>                 ],
>        # onlyif  => "hammer architecture list | /bin/grep 'x86_64' | 
> /usr/bin/wc -l",
>         onlyif => "/bin/echo 1",
>         user    => ccka,
>         environment     => ["HOME=/home/ccka"],
> }


Does anyone have an idea what's going wrong?

Regards,
Fredi

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/b44c8522-14e2-48a0-9459-7a2a6b0c3721%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to