Using the defaultfor method

The confine method is fine, but its usage may still result in multiple valid providers for a particular resource type. In this circumstance, the type should specify its preferred provider using the defaultfor method.

The defaultfor method uses a fact name and value as its arguments, which are then used to determine the default provider for certain types of underlying system.

For example, on Red Hat systems, both yum and rpm would be valid as providers to the package resource type, but the defaultfor method would be used to indicate that for Red Hat systems, yum is in fact the default provider, as shown in the following code:

Puppet::Type.type(:mynewtype).provide(:yum) do
...
confine :osfamily => :redhat
defaultfor: osfamily => :redhat
...
end
..................Content has been hidden....................

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