0

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?

1 Answer 1

1

I don't believe that this can work.

The commands method relies on another Provider class method which finally uses meta_def to create the method, which is then available inside the Provider class.

So the functionality is only available to actual subclasses of Puppet::Provider.

I think that the best shot at making this work would be to pull the whole functionality into a mixin module, which the Provider class would extend. Your own classes can do that as well then. (Not sure if this will really work in Puppet, though.)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .