Adding additional type properties

Type properties are attributes that reflect the current state of that resource on the underlying operating system.

During the Puppet run, these values are actively enforced, so they should be both discoverable and updatable. If the attribute can't be updated, it could be implemented as a read-only property. In the following code, we are extending our example type's interface to define a version property:

Puppet::Type.newtype(:mynewtype) do
...
mynewproperty(:version) do
end
...
end

Now we start to use that property in the Puppet DSL, as shown in the following code:

mynewtype{ 'foo':
version => '2.2',
}

But it won't allow the catalog to compile yet, since there's no implementation for that property in any corresponding provider, as shown in the following command:

$ puppet apply -e "mynewtype { 'foo': version => '2.2' }"
err: /Stage[main]// Mynewtype[foo]: Could not evaluate: undefined method 'version' for nil:NilClass
notice: Finished catalog run in 0.04 seconds

..................Content has been hidden....................

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