Home » Home » PUPPET PART 1: The First Step In Puppet.

A day in the life of System Admin is a non-fictional story, which is something System Admin do pretty often like putting  physical machine together, racked, cabled, and powered, and the operating system is installed. Then Add some user accounts and passwords, configure security settings and privileges, install all the packages needed to run the application, customize the configuration files for each of these packages, create databases and database user accounts; load some initial data and finally configure the machine for monitoring.

That’s a recursive work on System Admin life. It may take a day or a week if this is the first time you’re setting up the server. If you’re smart, you’ll write down everything you do, so next time you can simply run through the steps and copy and paste all the commands you need. Here comes the Puppet to help you on the recursive tasks.

This delightful series for System Admins, going to give a Kickstart on Puppet in Linux Ubuntu 12.04. Let’s get down to the business by installing Puppet and Puppet Master in Ubuntu 12.04. 

Prequisites:

To follow this series, you should be fluent with Debian native command lines like apt, sudo, dpkg, installing and configuring demon. Also it happen to work with PuppetMaster (also called Puppet Server) as well, so it requires to use a Virtual Machine has Ubuntu 12.04 instant or another physical machine which has same OS.  I assume you do the obvious stuffs to work around puppet.

HOW TO INSTALL PUPPET IN UBUNTU?

I’m using a Ubuntu 12.04 as primary OS to demonstrate PuppetMaster and Virtual Machine instant to demonstrate Puppet, the primary Ubnutu OS  has a host name “Master” and VM’s has a host name “Slave”.

We are going to use Slave OS that’s VM for Desktop automations, to install Puppet in Slave OS (VM) enter the following commands in Terminal

Slave$ sudo apt-get update

Slave$ sudo apt-get -y install puppet

Run the following command to check puppet is  properly installed.

Slave$ puppet –version

 

We will talk about the PuppetMaster installation and the configuration after few series because it is necessary to know more about the puppet desktop automation for getting the hands dirty with the PuppterMaster.

Hello World Script in Puppet

To see what Puppet code looks like, and how Puppet makes changes to a machine,we’ll create a manifest file and have Puppet apply it. Create the file anyname.pp anywhere you like, with the following contents:

file { ‘/tmp/hello’:

content => “Hello, world\n”,

}

Let me explain the first line of the code “file {‘/tmp/hello’:” The word file begins a resource declaration on the specified path that’s “/tmp/hello“,  this will create a file name hello under “/tmp” directory . Next line of the code will write the content  “Hello, world” into the file. The basic syntax of resource declaration is

RESOURCE {NAME:

ATTRIBUTE => VALUE,

}

To apply the script run the following command in Terminal, and navigate to /tmp directory to check the file and the content of it. 

Slave$  puppet apply anyname.pp

Slave$ cd /tmp

Slave$ cat hello

This is how the puppet works, pretty cool right!!! Okay, what if the “hello” file and the content of the file already exits with something else in the desired path.

Slave$ echo “This is puppet” > /tmp/hello

The above command will change the content of the hello file in /tmp dir, and again I’m going to apply the script anyname.pp to check the whether its changing or not.

Slave$ puppet apply anyname.pp

test

The result is surprising, applying the puppet overwrites the content of the file without any warning. So it’s always good to add a comment that puppet is managing the file or something else, just for the indication. 

Hope this article helps you to give a very first step on Puppet scripting. This journey will continue with lot of other stuffs related to files and packages for first few series, stay tuned and do lot of research on this to know more.

Leave a Reply

Your email address will not be published. Required fields are marked *

CAPTCHA Image

*