What is Puppet?
- Puppet is an open-source configuration management tool.
- It is a declarative language for expressing system configuration.
- Puppet is a client and server for distributing it.
- It is a library for realizing the configuration.
- Puppet is written in ruby and distributed under the GPL.
- Puppet is made by Luke Kanies.
- Currently puppet is supported by Puppet Labs(Luke Kanies is the CEO of Puppet Labs)
- Puppet code is written in manifests (files with .pp extension)
- In the code we declare resources that affect elements of the system (files, packages, services …)
- Resources are grouped in classes which may expose parameters that affect their behavior.
- Classes and configuration files are organized in modules.
- Configuration Management Advantage : Infrastructure as Code: Track, Test, Deploy, Reproduce, Scale.
- Alternatives to Puppet: Chef, CFEngine, Salt, Ansible
Puppet basic concepts
How Puppet Works ?
Server : puppetmasterd
Client : puppetd
- The connection between puppet agent and master is made in a secure encrypted channel with the help of SSL.
- The cleint connects to the server every 30minutes.
- The server compiles the configuration for the client, and compiles it and make it a catalog and sends it to the cleint.This catalog is given to the puppet agent of the node.
- The client checks the configuration it receives against what is really on the machine and tries to fix whatever is wrong.
- Node(cleint) configuration can be stored in LDAP, in a database or in the puppet configuration files.What Puppet Needs?
- ruby
- facter
- puppetFacter : Facter is a system profiling tool. It collects a plethora of system information like operating system, network interfaces, uptime, and so much more. Facter’s facts can be used when writing Puppet code so your code can always do the right thing without any investigative logic required.Puppet terminology and concepts :Resources :
Puppet ships with a number of pre-defined resources, which are the fundamental components of your infrastructure. The most commonly used resource types are files, users, packages and services. You can see a complete list of built-in resource types here.
Puppet revolves around the management of these resources. Let’s say, for example, we need to ensure that the ssh service is always up and running. The code below does this.service
{ ‘ ssh’: ensure => running, }
Manifests
Manifest are recipes that Puppet users to build the client configuration.
Manifests are the files that contain Puppet code. These files end with a .pp file extension. So if we wanted to save this ssh resource definition, we would save it in a manifest.
/etc/puppet/manifests/site.pp.
example :
class bacula - client {} node server - db { include bacula - client }
Classes
When we create a class, it’s really a set of configurations wrapped together — resources, variables and more advanced attributes. Anytime we assign this class to a machine, it will get those configurations. Here’s what the class definition looks like:
class openssh { package { ‘ openssh - server’: ensure => installed, }file {
‘
/etc/ssh / sshd_config’:
ensure => file,
owner => ‘root’,
mode => ‘0600’,
}service {
‘
ssh’: ensure => running,
}
}
This code wraps the resource declaration in a class, so that the puppet master can apply it to any node assigned that class. It doesn’t matter how many nodes are assigned to a class — it could be one, or one hundred.
Modules:
Puppet modules allow you to share the Puppet code that you or someone else has written to manage a piece of your infrastructure. If there is something that you want to manage with Puppet, there is probably a module for it on the Puppet Forge, which includes community-contributed modules, as well as those written by Puppet Labs employees. You’ll also find a list of Puppet Enterprise Supported Modules, which are written and tested by Puppet Labs employees. This list is constantly growing.
What is a Puppet module?
It’s really just a collection of files and directories that can contain Puppet manifests, as well as other objects such as files and templates, all packaged and organized in a way that Puppet can understand and use. When you download a module from the Forge, you are downloading a top-level directory with several sub-directories that contain the components needed to specify the desired state. When you want to use that module to manage your nodes, you classify each node by assigning to it a class within the module.
Now let’s put all these pieces together:
Resources can be contained within classes.
Classes can live in a manifest.
Manifests can live in a module.
Catalog
In order for the nodes in your environment to interpret the classes that have been assigned to them, Puppet compiles a catalog. The catalog describes the resources that need to managed, specifying the states those resources should be in, so each node can configure itself based on those definitions. Once the catalog is applied, the Puppet agent produces a report showing which resources were managed, and any changes that were needed to move into your desired state.
What are the Software related to Puppet ?
- Facter – Complementary tool to retrieve system’s data
- MCollective – Infrastructure Orchestration framework
- Hiera – Key-value lookup tool where Puppet data can be placed
- PuppetDB – Stores all the data generated by Puppet
- Puppet DashBoard – A Puppet Web frontend and External Node Classifier (ENC)
- The Foreman – A well-known third party provisioning tool and Puppet ENC
- Geppetto – A Puppet IDE based on Eclipse
Posted from my blog with SteemPress : https://www.golibrary.co/puppet-basic-concepts/