Puppet Resources

So far in Puppet Series at Thinknyx Technologies we have covered Installation and Configuration concepts:
Start Automation with Puppet

Puppet Enterprise Stack

Puppet Enterprise Master Installation

Puppet Agent Installation

Puppet Master-Agent Communication Model

Puppet Certification Management

Now its time to learn about Infrastructure as a code concepts and building blocks using Puppet Configuration Management tool.

Puppet

Puppet Resources:

Puppet Resources are the building blocks to put foundation of Puppet Codes. From simple Puppet codes to highly complex Puppet codes all consists of Puppet Resources. You can have a single resource or multiple resources grouped together in a Puppet Code. Some of the widely used Puppet resource types are user, group, file, package and service.

To look into all Puppet resources present by default with the puppet installation can be checked with a Puppet utility as:

puppet help resource

puppet resource –types

Note: These are the “core resource types”, Puppet provides the flexibility to create your own defined resource types and their usage as per application requirements. We will see such defined resource types when we learn about Puppet Modules.

Every Puppet resource is having three parts which we have to declare while creating any puppet code:

  • Resource Type

  • Resource Tittle

  • Resource Attributes

Lets see an example for the same to learn it in more depth, suppose we want to create a file /var/tmp/thinknyx with permissions 0777 and ownership & group as root:root. As puppet is a declarative model so we will not have to write big scripts with multiple variables, we just have to declare the attributes and rest will be taken care by the Puppet itself with the help of RAL (Resource Abstraction Layer).

file { ‘/var/tmp/thinknyx’:
ensure => ‘file’,
mode => ‘0777’,
owner => ‘root’,
group => ‘root’
}

Where “file” is a resource type

“/var/tmp/thinknyx” is a resource title

“ensure, mode, owner,group” are the resource attributes.

This code will create a file called /var/tmp/thinknyx with permissions 0777, ownership & group as root:root.

In our next post we will learn more about other Puppet Resources and will see how to find the resource attributes to be used in the codes.

1 thought on “Puppet Resources”

  1. Pingback: Puppet Resources-II – Thinknyx

Leave a Comment

Your email address will not be published.