Puppet: Writing multiple manifest for multiple clients

How to use multiple manifests in Puppet ?

Puppet always starts compiling with either a single manifest file or a directory of manifests that get treated like a single file. This main starting point is called the main manifest or site manifest.

If we need to write multiple files, then for  earlier versions of Puppet , we can use the import function to call  the other manifests in site.pp

             import "../classes/*"
             import "../nodes/*"


In Puppet 4, the import function is deprecated . I was getting the error below

Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Evaluation Error: Use of 'import' has been discontinued in favor of a manifest directory. See http://links.puppetlabs.com/puppet-import-deprecation at /apps/wps/puppetlabs/code/environments/production/manifests/site.pp:2:1 on node aus-lnaswgp-002.wiley.com

The solution is to put all the main manifests in Puppet manifests directory as per output of below command. 


       # puppet config print manifest
      /etc/puppetlabs/code/environments/production/manifests


In the above command , we will copy the nodes and classes folder to manifests directory. 



Accessing the manifest from Client:

Now to access the manifest from client , we will create the manifest file based on the hostname or FQDN of the client.

So , if the client name is node-002,then the manifest name for this host can be any of the following

  node-002.example.com, node-002.example,node-002,   
  NODE-002.example.com,NODE-002.example,NODE-002' on node   
  node-002.example.com

If the hostname does not match , when we will execute the puppet apply command , it will suggest what should be the manifest name with the below error . 


Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Could not find node statement with name 'default' or 'node-002.example.com, node-002.example, node-002, NODE-002.example.com, NODE-002.example, NODE-002' on node node-002.example.com
We just need to add a .pp after the manifest name. If there are multiple client nodes, then by following the above naming convention,we can create the manifest for the other node.We can do this for all other nodes. The manifests directory will look like this after we prepared the manifests for all clients. 

$ls /apps/wps/puppetlabs/code/environments/production/manifests/nodes    
node-001.example.com.pp  node-002.example.com.pp node-003.example.com.pp  node-004.example.com.pp  node-005.example.com.pp node-006.example.com.pp  node-007.example.com.pp

Now we will start applying the manifests by executing the below command from the respective servers, 

# puppet agent  -t
Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Caching catalog for node-002.example.com








......
......







Comments

Mr Rix said…
Hi

Today I want to show you a really absurd, but extremely effective "Manifestation Formula"

This will FORCE the universe to give you the life of your dreams - money, happiness, success, and more...

Follow this link to discover it...

==> Number 1 secret to manifest your dream life

I am talking about the kind of life that most people only ever fantasize and dream about.

The kind where you make more in a month than you used to in a year...

The kind where other people are inspired by you and want to impress YOU...

...Where you make your wildest dreams become a reality.

==> Click here to discover this secret

This secret will literally force the universe to give you all the tools that you need to create financial, emotional and spiritual abundance...

...Without hard work or struggle.

You'll achieve your wealth, health, relationships, and other personal goals...

...And life will all of a sudden get super exciting, you'll find it hard to sleep as you'll be so excited about each new day to come...

==> Manifest your dream life now

See you soon,

Enjoy and have a great day!

Popular posts from this blog

PSSH : Parallel SSH to execute commands on a number of hosts

How to add check_http as a service in Nagios Monitoring using NRPE

Configuring Nagios to monitor services using NRPE