Re: [Puppet Users] Re: using return value of a shell command as a puppet conditional

Ashley Gould
Mon, 31 Jan 2011 23:31:24 -0000

On Mon, Jan 31, 2011 at 02:14:29PM -0800, jcbollinger
wrote:
>
> On Jan 31, 3:12 pm, Ashley Gould <ago...@ucop.edu> wrote:
> > if [ "/usr/bin/my_harmless_binary 2>&1 >/dev/null"
]; then
> >   echo "my_harmless_binary succeeded"
> >   cp /tmp/file1 /data/
> > else
> >   echo "my_harmless_binary FAILED"
> > fi
>
> There are at least two possibilities.  The more general, more puppetly
> way is to write a custom fact that performs your test, and have your
> manifests test the value of the fact as needed to determine the
> appropriate configuration for the client.  Custom facts are easy to
> write and can be distributed through Puppet itself.  This approach
> does assume that the test is stable, however -- that is, that the
> result will not change between when the client requests its catalog
> and when it applies it.  Also, this isn''t so great if it could be
a
> problem for Puppet to apply a cached catalog compiled using an out-of-
> date test result.
>
> Alternatively, if the action you want to perform conditionally is a
> command that you would use an Exec for anyway, then making it
> conditional on some command is exactly what Exec''s
"onlyif" parameter
> is for.
>

thank you both. my current task will use a file action. I''m trying
to make puppet chose between alturnative versions of a file based on
the result of a binary.

I will work on the custom fact idea.  if such an issue is coming at
me so early in the game, then I may as well get started learning
how to build facts.




>
> John
>
> --
> You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
> To post to this group, send email to puppet-users@googlegroups.com.
> To unsubscribe from this group, send email to
puppet-users+unsubscribe@googlegroups.com.
> For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.

--

-ashley

Did you try poking at it with a stick?