Javatpoint Logo
Javatpoint Logo

Puppet Type and Provider

Puppet Types

Puppet types manage individual configuration items. Puppet provides a package type, a user type, a service type. And each type supports providers. In Puppet, there are two categories of types:

Defined Types: This type is written in DSL (Domain Specific Language) of Puppet.

Here, custom_user is a resource and $ensure, $home are attributes. This defined type can be consumed without worrying about the implementing resources:

Native Types: Native types are written in Ruby language. With the help of native type, we can determine resource interfaces much like the keyword 'define' in the Puppet DSL integrated with the type API.

Native types also called Ruby types. Unlike defined types, Ruby types depend on providers for the procedures used to handle the corresponding system.


Providers handle the configuration management on another platform or tool. Providers implement the procedure, and these procedures are used to manage the resources.

A resource has a collection of attributes, and the provider is used to manage that resource. Also, we can implement multiple providers for a single type. These providers let a similar resource to be applied to a different OS.

For any of its native types, Puppet offers several different providers. Such as, the user type of Puppet has eight providers that adopt support across various Linux and Windows platforms.

Package type has different providers such as DMG, yum, aptitude, and RPM. You can see the list of providers in package type in your system by the following command:

Puppet types and providers are written in Ruby language. Let's create a simple Puppet type called repo for managing repositories and providers such as SVN and Git. The 1st element of the repo type is the type itself, and these are typically located in lib/puppet/type or distributed by modules. First, create a file called repo.rb.

And copy the following content in the file:

In the above code, we have created a block, i.e., Puppet:: Type.newtype(: repo) do, that creates a new type, which we have called repo. We have mentioned @doc, which is the documentation section for the type. We also have defined an ensurable statement that creates a basic 'ensure' property. This 'ensure' property is used by puppet types to get the state of a configuration item.


The ensure statement informs the Puppet to except three methods in the provider:

  • Create: This command is used to generate the resource
  • Destroy: This is used to delete the resource, and
  • Exist: This is used to verify for the existence of the resource

Now, specify the contents of these methods, and Puppet builds the support system around them.

Now, define a new parameter named source:

The source parameter will inform the repo type where to go to download, clone, or search our source repository. The above script states if the source parameter starts with git, then use the Git provider, if not default, to the Subversion provider.

Define one more parameter called path:

Subversion Provider:

Next, define a provider as a block:

The code block informs the Puppet that this is a type repo provider called svn. Next, define the commands that this provider will use:

In Puppet, these commands are used to evaluate if the provider is suitable for use on a client. If the Puppet cannot get these commands in the local path, then the provider will be disabled.

Now, we can generate a resource:

Next TopicPuppet Template

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA