Puppet

  • Puppet is an open-source system management tool for centralizing and automating configuration management. Configuration management is the detailed recording and updating of information that describes an enterprise’s hardware and software.
  • Puppet is written using Ruby.
  • System Administrators usually perform repetitive tasks such as installing servers, configuring those servers, etc. They can automate this task, by writing scripts, but it is a very hectic job when you are working on large infrastructure.
  • To solve this problem, Configuration Management was introduced. Configuration Management is the practice of handling changes systematically so that a system maintains its integrity over time.

  • Puppet master gets the complete information about the node and takes a decision with the help of that information on how to apply the configuration.

For example, if suppose the node is Debian, then to install a package puppet we will use apt-get instead of yum.

 

ADDING NODES ON PUPPET

What are the Puppet nodes?

Puppet nodes are a block of Puppet code that will only be included in matching nodes’ catalogs. This feature allows you to assign specific configurations to specific nodes. Node statements are an optional feature of Puppet.

Before we add a node to a puppet, it needs a static IP address and a hostname. They need to either resolve in DNS or the host file which is managed by puppet.

The recommended way to add nodes is by using the AWS OpsWorks associateNode() API. The Puppet Enterprise master server hosts a repository that you use to install the Puppet agent software on nodes that you want to manage, whether nodes are on-premises physical computers or virtual machines.

To list all the nodes installed with the Puppet master we can use the below commands,

$grep -oi ‘node .* ‘ /etc/puppet/manifests/site.pp

or

$puppet cert list –all

 

FUNCTIONS ON PUPPET

There are many functions used on a puppet. Some examples of functions used in puppet are given below.

  • alert
  • assert_type
  • binary_file
  • break
  • contain
  • create_resources
  • crit
  • debug
  • defined
  • dig
  • digest
  • each
  • emerg
  • epp
  • err
  • fail
  • file
  • filter

Some examples using these functions are provided below,

SYNTAX

function <MODULE NAME>::<NAME>(<PARAMETER LIST>) >> <RETURN TYPE>

 {

  ... body of function ...

  final expression, which will be the returned value of the function

}





Eg.1: # Matching resource types

defined("file")

defined("customtype")




Eg.2: 

function break_if_even($x) {

  if $x % 2 == 0 { break() }

}

$data = [1,2,3]

notice $data.map |$x| { break_if_even($x); $x*10 }

CONFIG FILES

>> The main config file of Puppet is puppet.conf.

>> The puppet.conf. is always located under $confdir/puppet.conf.

>> Although its location is configurable with the config setting, it can only be set on the command line

(e.g. puppet agent -t –config ./temporary_config.conf).

Example of agent config

[main]
certname = agent01.example.com
server = puppet
environment = production
runinterval = 1h

Example of master config

[main]
certname = puppetmaster01.example.com
server = puppet
environment = production
runinterval = 1h
strict_variables = true

[master]
dns_alt_names = puppetmaster01,puppetmaster01.example.com,puppet,puppet.example.com
reports = puppetdb
storeconfigs_backend = puppetdb
storeconfigs = true
environment_timeout = unlimited

If you require help, contact SupportPRO Server Admin

Server not running properly? Get A FREE Server Checkup By Expert Server Admins - $125 Value

Leave a Reply