How to use 'commands' method in ruby code outside of puppet?

13 views
Skip to first unread message

Jakov Sosic

unread,
Sep 12, 2014, 11:43:54 AM9/12/14
to puppet...@googlegroups.com
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?
Reply all
Reply to author
Forward
0 new messages