Adding the namevar special attribute

After we make use of the special attribute of the type, that is its namevar, we can then actually use a declaration of our resource using the Puppet DSL. The namevar should identify the resource uniquely within the underlying operating system, and must be something that can be prespecified, as shown in the following code:

Puppet::Type.newtype(:mynewtype) do    mynewparam(:name, :namevar => true) do   end  end

Now, we can declare our resource in the Puppet DSL. In this case, the namevar defaults to the resource title, as shown in the following code:

mynewtype { ‘foo': }

The resource title is used to make a reference to the resource uniquely inside the Puppet catalog. Hence, the namevar indicates the underlying ...

Get Mastering Puppet 5 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.