Puppet Nodes

  • A node definition or node statement is 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. They can be replaced by or combined with an external node classifier, or you can eschew both and use conditional statements with facts to classify nodes.

• Unlike more general conditional structures, node statements only match nodes by name. By default, the name of a node is its certname (which defaults to the node’s fully qualified domain name).


Roles Define Policy

• When clients connect, the Puppet Master generates a catalog with the list of the resources that clients have to apply locally.

• The Puppet Master has to classify nodes and define for each of them:

• The classes to include

• The parameters to pass

• The Puppet environment to use

• The catalog is generated by the Master according to the logic of our Puppet code and data.

• In our code we can define our variables and use other ones that may come from different sources:

• facts generated directly by the client

• parameters obtained from node's classification

• Puppet internal variables


Nodes – Default Classification

• A node is identified by the PuppetMaster by its certname, which defaults to the node's fqdn

• In the first manifest file parsed by the Master, site.pp, we can define nodes with a syntax like: node 'web01’ { include apache }

• We can also define a list of matching names: node 'web01' , 'web02' , 'web03’ { include apache }

• or use a regular expression: node /^www\d+$/ { include apache }

• A node can inherit another node and include all the classes and variables defined for it, this feature is now deprecated and is not supported anymore on Puppet 4.


Exercise  - Puppet Nodes

 Go to master terminal and open site.pp and add following code

cd /etc/puppet/manifests

nano site.pp

node default {

notify {“The default puppet configuration”: }

}

node /^puppet/ {

notify {“We have matched the Puppet node”: }

}

 Go to the master terminal and run this command.

puppet apply site.pp

 Create a file nodes.pp in master terminal window and add the following text to it.

cd /etc/puppet/manifests

nano nodes.pp

package {'openssl':

ensure => present,

before => File['/etc/ssh/sshd_config'],

}

file {'ssh-config':

ensure => file,

path => '/etc/ssh/sshd_config',

mode => 600,

source => '/root/examples/sshd_config',

}

service {'ssh':

ensure => running,

enable => true

subscribe => File['etc/ssh/sshd_config'],

}

puppet apply nodes.pp

Comments

Popular posts from this blog

Different Types of Reports in Scrum - Agile

Terraform

Scrum Master Interview help - Bootcamp