In my previous article, titled,“Puppet: Writing simple manifests” , I wrote about how to write simple manifest to create a user.
In this article, we are going to see more complex way of writing manifests using “modules”.
We will see how can we write a simple module called “motd” and display the banner when we login to any puppet-client.
Please follow below steps in sequence:
- Please change to “/etc/puppetlabs/code/environments/production/modules” in Puppet-Master.
2. Now create below Directories as mentioned below:
3. Now go to “manifests” directory inside “motd” directory and create “init.pp” file such that it has entry as below:
4. Now go to files Directory and create a file named “motd” like below.
You can create “motd” like below using some professional banner generator using below link:
5. Now go to “/etc/puppetlabs/code/environments/production/manifests” directory and modify “site.pp” to look like below:
6. Now run below commands in sequence:
puppet parser validate site.pp
puppet apply — noop site.pp
puppet apply site.pp
7. Now logout / log back in in Puppet-Master server. You will see the banner when you login:
8. Now login to Puppet-client and run below command:
puppet agent -t
9. Now try to log out / log back in to puppet-client , you should get something like below as banner when you login.
That’s It. We are done !!
Point to remember
For our example , same result can be achieved if we write site.pp like below. This will set banner on all the servers:
However for better understanding, we have written “site.pp” like earlier in our example so that we can set banners on selective servers only.