On Friday, November 15, 2013 1:33:19 PM UTC-6, Stuart Cracraft wrote:
>
> In good shape here. Got everything up and running yesterday and today.
>  
> My current question I've posted at the main level.
>  
> I just want to get at the value (exit status and/or standard output) 
> returned from
> any arbitrary Unix command puppet would run.
>  
> So the question is is there a way to get exec's output (all of it) into a 
> variable
> and for the exit status.
>  
>


No.  Puppet variables are meaningful only to the puppetmaster, during the 
catalog compilation process.  By the time you are applying the catalog to 
the target node (so that an Exec's command is run), catalog compilation is 
necessarily complete.

As I said, though, you can create a custom fact that executes whatever 
command you like on the target node -- before catalog compilation -- and 
returns its output.  It would be slightly trickier, but I think still 
possible, to capture the output and exit status into separate facts (or 
even not so tricky if you were willing for Facter to run the command twice).

Alternatively, you can write a custom provider, either for an existing type 
or for a new, custom one, that captures command output and exit status in 
*Ruby* variables, and does whatever you want with them within the scope of 
applying a resource of the given type.

As Felix observed, your design concept may not be well aligned with 
Puppet's mode of operation.  Puppet wants to gather up front all the 
information needed to compute the details of the target configuration, then 
to compile the chosen configuration details into a compact representation, 
and finally to update the target node to match the configuration details.


John

-- 
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/ad852d98-6e02-4d1e-ab27-78866e0dc47f%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to