What is Puppet?

The Traditional IT Industry

Ever since the revolution of the IT industry, there has been a gap between the Developers (Dev) and the Operators (Ops). Developers are the ones who would write up code, build applications, analyze systems and fix bugs while the Operators or System Administrators would build servers and manage them. But now that we have Configuration Management Systems, Developers and Operators are just people who work around the code.

The Problem

Person A joins your company as a Support Engineer. They are supposed to work with 5 servers. Now what would traditionally happen is that the team lead would login into the 5 machines one-by-one and create a user as well as give required access or permissions to that user on the 5 servers. This was a tiresome and irritating task. Think about it, what if there are a 100 servers?

The Solution

Puppet came into existence. Puppet is an automation tool which can be used to configure remote machines easily. Install Puppet Server on your machine and Puppet Client on the machines you wish to manage. Now you can sit on your local machine which has Puppet Server installed and run configurations which would create users, install applications, stop services or almost anything on the remote machines with a single touch of a key.

What would happen is that every 30 minutes (you can change this time), The Puppet master would go to the Puppet clients and check if they are in the desired state. The Puppet master would move on on to the next client if it is in the desired state. In case the Puppet client is not in the desired state, it would instruct the client machine to modify itself as per the required needs.

What is the desired state?

The desired state is actually a state set by the Puppet master. For example, the Puppet master has set the current desired state to be a scenario where all machines have a file created in their /tmp directory. Puppet Master will then go to every client machine to check whether the file is present in the correct location on that machine or not, if it is present then the machine is in the desired state, otherwise it is not. A machine which is not in a desired state is called a Drift.

Components of Puppet

Puppet has a simple operating model. It has 3 major components:

  • Deployment Layer
  • Configuration Language and Resource Abstraction Layer
  • Transactional Layer

Understanding the Puppet Deployment Layer

Puppet is usually deployed in a simple client-server model. The server is called a Puppet master, the Puppet client software is called an agent, and the host itself is defined as a node. The Puppet master runs as a daemon on a host and contains the configuration required for the specific environment.

The Puppet agents connect to the Puppet master through an encrypted and authenticated connection using standard SSL, and retrieve or “pull” any configuration to be applied. Importantly, if the Puppet agent has no configuration available or already has the required configuration, Puppet will do nothing. Puppet will only make changes to your environment if they are required. This property is called idempotence and is a key feature of Puppet. The whole process is called a configuration run.

What Exactly is Idempotence?

I have an account with Axis bank and I also have the Axis Bank mobile app installed on my phone. I use the app for transactions and checking my account balance. Let’s suppose that I check my balance 10 times within a minute. Will it affect my account balance? It will not unless a transaction is made from my account or someone deposits money in it. This is the property of Idempotence, even though you perform a task using the same steps multiple times, if you have received the desired output then you can successfully perform the task again and again but it will not change anything since the desired output has been received.

The Configuration Language and Resource Abstraction Layer

Puppet uses a declarative language, the Puppet language, to define your configuration items, which Puppet calls resources. Being declarative creates an important distinction between Puppet and many other configuration tools. A declarative language makes statements about the state of your configuration—for example, it declares that a package should be installed or a service should be started.

Most configuration tools, such as a shell or Perl script, are imperative or procedural. They describe how things should be done rather than the desired end state—for example, most custom scripts used to manage configuration would be considered imperative.

Puppet handles the “how” by knowing how different platforms and operating systems manage certain types of resources. Each type has a number of providers. A provider contains the “how” of managing packages using a particular package management tool. The package type, for example, has more than 20 providers covering a variety of tools, including yum, aptitude, pkgadd, ports, and emerge.
When an agent connects, Puppet uses a tool called Facter to return information about that agent, including what operating system it is running. Puppet then chooses the appropriate package provider for that operating system and uses that provider to check if the vim package is installed.

For example, on Red Hat it would execute yum, on Ubuntu it would execute aptitude. If the package is not installed, Puppet will install it. If the package is already installed, Puppet does nothing.

Transactional Layer

Puppet’s transactional layer is its engine. A Puppet transaction encompasses the process of configuring each host, including these steps:

• Interpret and compile your configuration.

• Communicate the compiled configuration to the agent.

• Apply the configuration on the agent.

• Report the results of that application to the master.

Understanding the Puppet Eco-system

1. Written in Ruby and released with an open source license (Apache 2), it can run on any Linux distribution, many other UNIX variants (Solaris, *BSD, AIX, and Mac OS X), and Windows.

2. Started in 2005 by Luke Kanies as an alternate approach to the existing configuration management tools (most notably, CFEngine and BladeLogic).

3. Original name of company was Reductive Labs, which was renamed in 2010 to Puppet Labs, has received a total funding of $45.5 million in various funding rounds (among the investors, there are names such as Vmware, Google, and Cisco).

4. Now, it is one of the top 100 fastest growing companies in the US. It employs more than 250 people, and has a solid business based on open source software, consulting services, training, and certifications.

5. It also has Puppet Enterprise, which is the commercial version that is based on the same open source Puppet code base, but it provides a web GUI that improves and helps in easier Puppet usage and administration.

More Knowledge

If you are new to the world of Linux I’d recommend going with: RHCSA Training
Want to learn Puppet? Checkout: Puppet Training
If you are an expert with Linux, grow your career with RHCE, AWS, Devops, Openstack or Openshift.