Puppet has a client server architecture, where the server is called puppet master (written in ‘ruby on rails’). Master and nodes communicates on port tcp/8140.
Individual configuration items in a puppet programs are called resource declaration. A resource declaration answers 2 questions, what aspect of the system it is going to manager and what state it should be in.
RD have 4 parameter Type, Title, Attributes, Provider.
‘Type’ or ‘Resource type’ defines the type of resource to manage for example: Packge, File, Service

node 'db01' {
  package { 'ntp' :		# package is Type and ntp is title
    ensure => 'installed'	# Attributes

Resource Provider does the heavy lifting to implement the desired configuration. puppet automatically selects the best one. There will be different provider depending on resource type and OS, for example Package resource type have different provider based on RHEL(yum) Ubuntu(apt).

Configuration Run:
Configuration Run is process of running a puppet program. The complete process is as follows.

  1. pupet agent on the node connects to the puppet master on port tcp/8140.
  2. It then sends facts about itself.
  3. Puppet master after receiving the facts classify the node and apply matching definitions.
  4. It then compiles a catalog and sends it back to the node.
  5. The agent on the node applies the catalog and repots back.

Installing and Configuring Puppet
Download the Puppet repository and install puppet master

yum install 
yum install puppet-server -y 
puppet master --version

Diretory Environment:
Puppet programs are stored in files called manifest. These manifests contains node definition and resource declaration. By default puppet looks into /etc/puppet/manifests/site.pp. To build a directory environment we can create subdirectory under /etc/puppet/environments/ like ‘production’ ‘development’ etc. Each environment can have environment related configuration stored in repective directory for example /etc/puppet/environment/prod/environment.conf
Puppet configuration file is stored in /etc/puppet/puppet.conf and contains 3 sections ‘Master’, ‘Agent’, ‘Main’.
My puppet.conf file looks something like this

    logdir = /var/log/puppet
    rundir = /var/run/puppet
    ssldir = $vardir/ssl
    classfile = $vardir/classes.txt
    localconfig = $vardir/localconfig

We need to enable diretory environment by add Master config

    environmentpath = $confdir/environments/
    basemodulepath = $confdir/modules

We also need to create a SSL certificte for the master/node communication, to generate SSL keys run the below command.
puppet master --verbose --no-daemonize Installing Agent:
In order to install puppet agent on the client, fisrt add the hostname of master in /etc/hosts of the client and then install puppet repo and agent.

yum install
yum install puppet -y

After installing the puppet agent we need to tell this node who his master is by editing /etc/puppet/puppet.conf

server = master

Now we can generate the agent certificate. puppet agent --verbose --no-daemonize --onetime `