Resource Types: Index

List of Resource Types

About resource types

Built-in types and custom types

This is the documentation for the built-in resource types and providers, keyed to a specific Puppet version. (See sidebar.) Additional resource types can be distributed in Puppet modules; you can find and install modules by browsing the Puppet Forge. See each module’s documentation for information on how to use its custom resource types.

Declaring resources

To manage resources on a target system, you should declare them in Puppet manifests. For more details, see the resources page of the Puppet language reference.

You can also browse and manage resources interactively using the puppet resource subcommand; run puppet resource --help for more information.

Namevars and titles

All types have a special attribute called the namevar. This is the attribute used to uniquely identify a resource on the target system.

Each resource has a specific namevar attribute, which is listed on this page in each resource’s reference. If you don’t specify a value for the namevar, its value defaults to the resource’s title.

Example of a title as a default namevar:

file { '/etc/passwd':
  owner => 'root',
  group => 'root',
  mode  => '0644',
}

In this code, /etc/passwd is the title of the file resource.

The file type’s namevar is path. Because we didn’t provide a path value in this example, the value defaults to the title, /etc/passwd.

Example of a namevar:

file { 'passwords':
  path  => '/etc/passwd',
  owner => 'root',
  group => 'root',
  mode  => '0644',

This example is functionally similar to the previous example. Its path namevar attribute has an explicitly set value separate from the title, so its name is still /etc/passwd.

Other Puppet code can refer to this resource as File['/etc/passwd'] to declare relationships.

Attributes, parameters, properties

The attributes (sometimes called parameters) of a resource determine its desired state. They either directly modify the system (internally, these are called “properties”) or they affect how the resource behaves (for instance, adding a search path for exec resources or controlling directory recursion on file resources).

Providers

Providers implement the same resource type on different kinds of systems. They usually do this by calling out to external commands.

Although Puppet will automatically select an appropriate default provider, you can override the default with the provider attribute. (For example, package resources on Red Hat systems default to the yum provider, but you can specify provider => gem to install Ruby libraries with the gem command.)

Providers often specify binaries that they require. Fully qualified binary paths indicate that the binary must exist at that specific path, and unqualified paths indicate that Puppet will search for the binary using the shell path.

Features

Features are abilities that some providers might not support. Generally, a feature corresponds to some allowed values for a resource attribute.

This is often the case with the ensure attribute. In most types, Puppet doesn’t create new resources when omitting ensure but still modifies existing resources to match specifications in the manifest. However, in some types this isn’t always the case, or additional values provide more granular control. For example, if a package provider supports the purgeable feature, you can specify ensure => purged to delete configuration files installed by the package.

Resource types define the set of features they can use, and providers can declare which features they provide.