getting output from command in custom provider

236 views
Skip to first unread message

ZJE

unread,
Aug 13, 2012, 2:55:23 PM8/13/12
to puppet...@googlegroups.com
Is the output of a command called by puppet stored somewhere on the master or agent?

For example, if have the statement
---
commands :ls => "ls"
---

and then I try something like " ls, '/' "

where does the output of "ls /" go? I've tried poking around in vardir on both the master and the agent with no luck. I'm probably just missing it, but this would help with some debugging. I'm looking for both stdout and stderr.

Note: I'm not actually running ls, I figured it was an easy example of a command that writes to stdout/stderr

Thanks!

Josh Cooper

unread,
Aug 13, 2012, 3:23:39 PM8/13/12
to puppet...@googlegroups.com
On Mon, Aug 13, 2012 at 11:55 AM, ZJE <count...@gmail.com> wrote:
>
> Is the output of a command called by puppet stored somewhere on the master or agent?
>
> For example, if have the statement
> ---
> commands :ls => "ls"
> ---
>
> and then I try something like " ls, '/' "
>
> where does the output of "ls /" go? I've tried poking around in vardir on both the master and the agent with no luck. I'm probably just missing it, but this would help with some debugging. I'm looking for both stdout and stderr.

Puppet doesn't capture the output of commands in a persistent way like
it does with the `logoutput` parameter for the exec type. It does get
written to a tempfile, but deleted soon after.

However, you could easily modify lib/puppet/provider.rb, line 121 (in
2.7.x), to output the result of calling `execute(cmd)`. That call will
return the combined stdout and stderr output as a string.

Josh

--
Josh Cooper
Developer, Puppet Labs

Stefan Schulte

unread,
Aug 13, 2012, 8:53:14 PM8/13/12
to puppet...@googlegroups.com
On Mon, Aug 13, 2012 at 11:55:23AM -0700, ZJE wrote:
> Is the output of a command called by puppet stored somewhere on the master
> or agent?
>
> For example, if have the statement
> ---
> commands :ls => "ls"
> ---
>
> and then I try something like " ls, '/' "

this does not seem right. The above command method marks the provider as
unsuitable if the ls command is not present and creates a method with
the name ls. So if you want to execute ls you do:

output = ls('-l', '/tmp')

>
> where does the output of "ls /" go?

it is the return value of the method "ls"

-Stefan

Reply all
Reply to author
Forward
0 new messages