Creating types

Types are created by calling the newtype method on the Puppet::Type class:

# lib/puppet/type/database.rb
Puppet::Type.newtype(:database) do
  @doc = "Create a new database."
  # ... the code ...
end
The name of the type is the only required argument to newtype. The name must be a Ruby symbol, and the name of the file containing the type must match the type's name.

The newtype method also requires a block of code, specified with either curly braces ({ ... }) or the do ... end syntax. The code block implements the type, and contains all of the properties and parameters. The block will not be passed any arguments.

You can optionally specify a self-refresh option for the type by putting :self_refresh => true after the name. Doing so causes resources of this type to refresh (as if they had received an event through a notify-subscribe relationship) whenever a change is made to the resource. A notable use of this option is in the core mount type.