[Puppet Users] How to use 'commands' method in ruby code outside of puppet?

Jakov Sosic
Fri, 12 Sep 2014 15:43:26 -0000

Hi,

to allow me to easier debug my providers, I sometimes wanna use
'command' in my own ruby code.

Trying to figure out how is problem.

This is how I use it inside a provider:

   commands :wget    => '/usr/bin/wget',
            :cp      => '/bin/cp'

Later, I can run the command with simple:

wget('http://example.com')



Now, I tried doing this:

something = Puppet::Provider.commands({:wget => '/usr/bin/wget'})
something.wget('http://example.com')

but, I get this:


test.rb:15: undefined method `wget' for
{:wget=>"/usr/bin/wget"}:Hash
(NoMethodError)


I also tried running:

wget = Puppet::Provider::Command.new('wget', '/usr/bin/wget',
Puppet::Util, Puppet::Util::Execution)
puts
Puppet::Util::Execution.execute(['wget','http://example.com'],{})

but the output is blank...


Any ideas?

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-users/5413149E.8000009%40gmail.com.
For more options, visit https://groups.google.com/d/optout.