Using the commands method

Confining providers may also be based on the availability of certain commands from the system path using the commands method.

More importantly, by using the special methods generated by commands, we can also inform Puppet of the correct commands for interacting with the underlying system. This is preferable over Ruby's own methods for command execution, such as %x{cmd} or cmd for the following reasons:

  • Puppet displays commands invoked this way when the --debug flag is set
  • They are documented as a requirement for the provider
  • Exceptions are handled consistently by raising a Puppet::ExecutionFalure

This is shown in the following code:

Puppet::Type.type(:mynewtype).provide(:yum) do
...
commands :yum => 'yum', :rpm => 'rpm'
...
end
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.27.232