Top Puppet Interview Questions (2024)
What is Puppet?
What are the benefits of using Puppet in devops?
What is Puppet Master?
What is Puppet Agent?
What are the ways to install the Puppet?
Why NTP is used in Puppet?
What is the command to install the Puppet Master on Linux based server?
What is Puppet Configuration Repository?
Explain Puppet architecture and how it works?
What does Puppet Agent -tv command do?
What are Puppet Classes?
What is the Puppet manifest?
How to find the path for the manifest for the primary server in puppet?
What is Puppet Site Manifest?
What is the Puppet Modules?
What is the Puppet Resource?
What are Puppet resource types?
What is Puppet Node definitions?
What if you don't want to run the node definition in all of the puppet agent nodes in the given environment?
What are the ways to check for syntax errors in puppet code?
How to apply Node definitions to all nodes in Puppet?
How can we make sure our puppet agents are running the same version as our primary server?
How to install ntp, sync the date and time and check the status in Puppet Master Node?
How to start the Puppet Server and check status?
How to install Puppet Agent?
How do we sign the Puppet Agent's Certificate?
How to apply Puppet Master Nodes Configuration to the agent?
What is Puppet Variable?
What is Puppet Facts and Facter?
What is the use of Puppet Roles and Profiles?
What is purpose of Hiera in Puppet?
What is Puppet Mcollective?
Q: What is Puppet?
Ans:
Puppet is an open-source DevOps tool. Puppet tool is developed in Ruby DSL (domain-specific language), used for centralize server configuration management and automation. This tool deploys, configures, and manages servers.
Q: What are the benefits of using Puppet in devops?
Ans:
- Automate configuration management : Rather than executing operations manually or writing complex scripts, utilise a simple, resilient, stable, and easy-to-use configuration management solution such as Puppet.
- Simple to use: Can combine several manual steps with the ease of puppet in the form of puppet code, which is nothing more than infrastructure as code (IaC). IaC (infrastructure as code) refers to the process of configuring and managing infrastructure using code-based files.
- Puppet gives the option to modify existing code quickly and duplicate it across our entire environment in minutes.
- IAC fills the gap between Dev and Ops, supporting in the formation of true DevOps teams.
- Puppet applies and then idempotently, which means puppet code output is consistent and identical regardless of time or context.
Q: What is Puppet Master?
Ans:
Puppet Master plays an important role in managing all configuration-related jobs. The configuration is applied to all target nodes or client machines.
Take a look at our suggested post :
Q: What is Puppet Agent?
Ans:
The Puppet Agent is the application that controls our nodes (node servers) configurations. To retrieve configuration catalog, a Puppet primary server is required.
Q: What are the ways to install the Puppet?
Ans:
There are two ways we can deploy the Puppet environment:
Master Agent deployment
Master-Agent based deployment is mainly used for Production environment. Where there would be one Master Server and all other are Agent server nodes.Self Contained deployment
The self-contained approach is suitable for POC or testing, as the same server can work as both master and agent.
Q: Why NTP is used in Puppet?
Ans:
NTP (Network Time Protocol) is one of the most important, yet simple, services to create and operate using Puppet in order to synchronize time throughout our all server nodes. Ensure that all of our configuration management tools are in sync with one another.
Q: What are the ways to install the Puppet Master?
Ans:
- In Linux - install puppet server
-yum install puppetserver
- In Ubuntu, we could use below command:
apt-get install puppetserver
- There are also alternative choices, such as installing from the source via git or constructing from source.
Q: What is Puppet Configuration Repository?
Ans:
A centralized area in which all configurations are saved and retrieved by the Puppet master as needed.
Q: Explain Puppet architecture and how it works?
Ans:
The Puppet workflow procedure is as follows:
- Using Facts, the Puppet agent sends data about its present condition to the Puppet master.
- Facts provide information about the system such as the IP address, hostname, FQDN, kernel version, and much more. It returns a list of key-value pairs known as Facts.
- The Facts are then used by puppet to construct a catalogs that outlines how the agent should be configured.
- Puppet Master builds a catalog that is the difference between the expected and current running agent configurations and gives it back to the agent to execute the differences. This is how the desired state and the running state remain consistent.
- Puppet Agent immediately responds to changes after receiving the catalog from Puppet Master by executing configuration changes or implementing newly configured configurations. Throughout the procedure, the agent reports to Puppet Master that the configuration has been applied and completed.
Q: What does Puppet Agent -tv command do?
Ans:
puppet agent -tv
OR puppet agent --test
, instructs the Puppet Agent to
fetch a catalog from a Puppet Master and apply it locally and quickly.
Q: What are Puppet Classes?
Ans:
Puppet classes are defined as a collection of resources that are put together to achieve the desired state of a target node or machine. These classes are declared within Puppet manifest files, which are found within Puppet modules.
Classes are defined first and then declared to be used in the puppet code.
Syntax:
class <class-name>{
{
<Resource declarations>
}
}
include <class-name>
Example:
#/etc/puppetlabs/code/environments/production/manifests/test.pp
class testExample{
file { '/etc/test':
ensure => "present",
content => "TechGeekNext Test File",
}
}
#Declar the class
include testExample
Q: What is the Puppet manifest?
Ans:
A manifest is a directory that contains Puppet configuration language and defines how to configure resources. Manifests are the terms used to refer to puppet programs. Manifests are made up of puppet code, and their filenames end with extension .pp (puppet program). The puppet code consists of definitions or declarations of Puppet Classes.
There could be a single file or multiple files inside manifest directory.
The main manifest for an environment is by default <ENVIRONMENTS DIRECTORY>/<ENVIRONMENT>/manifests
,
for example /etc/puppetlabs/code/environments/production/manifests
.
User can configure the manifest per environment, as well as the default for all
environments.
Q: How to find the path for the manifest for the primary server in puppet?
Ans:
The default path for the manifest directory for the primary server with given environment can be found by executing puppet config command.
puppet config print manifest --section server --environment <ENVIRONMENT>
Q: What is Puppet Site Manifest?
Ans:
The main file used by Puppet to define global system configuration is the site manifest (site.
pp
).
Site.pp
is the main puppet file, found in the directory /etc/puppetlabs/code/environments/production/manifests
, in which user can declare all of the puppet
classes using the include keyword.
Inside the site, the user can declare various classes.
[root@puppetmaster manifests]# cat site.pp
#Class Definition
class testExample{
file { '/etc/test':
ensure => "present",
content => "TechGeekNext Test File",
}
package { 'ntp':
ensure => "present",
}
}
#Declare the class
include testExample
Q: What is the Puppet Modules?
Ans:
Modules are a collection of files and folders that function together and adhere to a specified directory structure, such as manifests, class definitions, and any other dependent files. In Puppet, units are reusable and shareable.
Q: What is the Puppet Resource?
Ans:
The primary unit for modelling system configurations is the resource. Each resource describes a different parts of the system, such as a particular service or package.
A resource declaration is an expression that describes a resource's desired state and instructs Puppet to add it to the catalogs.
Q: What are Puppet resource types?
Ans:
Every resource has a resource type linked with it, which indicates the type of configuration it handles.
Puppet includes a variety of resource types, such as files, cron jobs, and services. For further information on the built-in resource types, see the resource type reference.
Every resource has a resource type, a title, and a set of attributes:
Syntax:
<RESOURCE-TYPE> { '<TITLE>':
<ATTRIBUTE> => <VALUE>,
}
Example:
file { '/etc/test':
ensure => "file",
content => "TechGeekNext Test File",
}
Puppet can also be extended with new resource types:
- Defined types are simple resource types written in the Puppet programming language.
- Custom resource types are developed in Ruby and have the same features as built-in Puppet types.
Q: What is Puppet Node definitions?
Ans:
A node definition, also known as a node statement, is a piece of Puppet code that included only in matching nodes catalogs. This helps to allocate different settings to different nodes.
Add node definitions in the main manifest, which might be a single site.pp file or a directory
with several files.
If we run the puppet agent on any node controlled by the puppet master, the node will
automatically pick the code and execute it.
Syntax:
node <node-name>{
include <class-name1>
include <class-name2>
}
Q: What if you don't want to run the node definition in all of the puppet agent nodes in the
given
environment?
Ans:
This is where puppet comes in handy by allowing us to use Node Definitions. According to standard practices, we never put puppet code inside the site.pp file. In general, this file is intended for Node Definitions.
#/etc/puppetlabs/code/environments/production/manifests/test.pp
class testExample{
file { '/etc/test':
ensure => "present",
content => "TechGeekNext Test File",
}
}
Specify the node server, for example, agent1.test.com
below in node definition to
which the configuration should be applied.
#/etc/puppetlabs/code/environments/production/manifests/site.pp
node 'agent1.test.com'{
include testExample
}
Q: What are the ways to check for syntax errors in puppet code?
Ans:
Syntax validation can be validated in a different ways.
- Execute below command directly from live environment.
#to validate one file $ puppet parser validate testExample.pp #to validate two files $ puppet parser validate testExample.pp config.pp
- Integration in continuous integration tool. Puppet parser allows us to validate Puppet code to ensure that it is free of syntax errors.
- Can Check code with Vim editor quickly with built in code compilation functionality.
- Plugins/Tools: Syntastic , puppet-lint
Q: How to apply Node definitions to all nodes in Puppet?
Ans:
In the puppet node definition file, use the default keyword.
All nodes that aren't defined anywhere in the node definition file will be handled by the default section.
#/etc/puppetlabs/code/environments/production/manifests/site.pp
node 'agent1.test.com'{
include testExample
}
node 'default'{
# include any class which needs to be applied to all except the above node (agent1.test.com)
}
Q: How can we make sure our puppet agents are running the same version as our primary
server?
Ans:
Set the package_version
variable for the puppet_agent
class to auto
in the puppetlabs-puppet_agent
module to ensure our agents are always running the
same version as our primary server. After a primary server upgrade, this forces agents to
automatically upgrade itself during their first Puppet run.
Q: How to install ntp, sync the date and time and check the status in Puppet Master Node?
Ans:
- Install ntp service on puppet-master using below command.
[root@puppet-master ~]# yum install ntp -y
- Sync the date and time using below command.
[root@puppet-master ~]# ntpdate centos.pool.ntp.org
- Restart the NTP Service.
[root@puppet-master ~]# systemctl restart ntpd
- Check the NTP service status.
[root@puppet-master ~]# systemctl status ntpd
- Enable the NTP service.
[root@puppet-master ~]# systemctl enable ntpd
Q: How to start the Puppet Server and check status?
Ans:
- We can start the puppet service using below command.
root@puppet-master ~]# systemctl start puppetserver
- Check the puppetserver service status.
[root@puppet-master ~]# systemctl status puppetserver
- Now enable the puppetserver.
[root@puppet-master ~]# systemctl enable puppetserver
Q: How to install Puppet Agent?
Ans:
- Install Puppet Agent using below command.
[root@puppet-agent ~]# yum -y install puppet-agent
-
Start the Puppet Agent:
[root@puppet-agent ~]# /opt/puppetlabs/bin/puppet resource service puppet ensure=running enable=true Notice: /Service[puppet]/ensure: ensure changed 'stopped' to 'running' service { 'puppet': ensure => 'running', enable => 'true', }
Q: How do we sign the Puppet Agent's Certificate?
Ans:
The Puppet Agent's Certificate must be signed in order to communicate with the Puppet Master.
- We can find the agents managed by our master using puppet cert all command.
[root@puppet-master ~]# /opt/puppetlabs/bin/puppet cert list + "puppet-agent-demo1" (SHA256) 53:FA:G4:6F:60:TD
- Sign the Certificate.
[root@puppet-master ~]# /opt/puppetlabs/bin/puppet cert sign puppet-agent-demo1 Signing Certificate Request for: "puppet-agent-demo1" (SHA256) 53:FA:G4:6F:60:TD
- Check all the Signed Certificate.
[root@puppet-master ~]# /opt/puppetlabs/bin/puppet cert list --all</li>
Q: How to apply Puppet Master Nodes Configuration to the agent?
Ans:
Execute below command to apply Puppet Master Nodes Configuration to the agent nodes:
[root@puppet-master ~]# puppet agent -tv
Q: What is Puppet Variable?
Ans:
Variables are used to store data so that it can be retrieved later. To make puppet code management more flexible, Puppet uses variables to reuse the same parameters.
- The dollar
$
sign is always prefixed to variables, and values are assigned with an equal to (=
) sign. - Lowercase and uppercase letters, numerals, and underscores can all be used in variable names, which are case sensitive.
class <class-name>{
$<variable-name> = <value>
}
Example:
class testExample{
$message = "TechGeekNext Test File"
file { '/etc/test':
ensure => "present",
content => "$message",
}
}
Q: What is Puppet Facts and Facter?
Ans:
- Facts are a way of getting information about puppet agents like information about network,Host, kernel, IP address, CPU, memory etc.
- Facter is a Puppet utility. It is used to provide these agents information.
- Facter's output is in the form of key-value pairs, commonly known as Facts.
Q: What is the use of Puppet Roles and Profiles?
Ans:
- Roles and profiles helps in the management of a rapidly expanding puppet environment. Puppet Roles and Profiles are equivalent to puppet modules in terms of functionality.
- Multiple puppet modules can be included in puppet profiles, and defined puppet profile modules can be included in Puppet Roles. This allows us to keep the main manifest small and manageable.
- We can use puppet profiles and roles in environments with additional groups such as dev, test, uat, Prod.
Q: What is purpose of Hiera in Puppet?
Ans:
Hiera enables us to move sensitive and confidential data out of code files and into a separate data-storage file. Hiera is the built-in data lookup solution for puppet's key value configuration.
Example:
#/etc/puppetlabs/code/environments/production/manifests/test.pp
class testExample{
file { '/etc/test':
# servers value will be fetched from hiera.yml
servers => "*****",
content => "TechGeekNext Test File",
}
}
hiera.yml
---
testExample::servers:
- abc.ntp.com
Q: What is Puppet Mcollective?
Ans:
Mcollective, commonly known as Marionette Collective, is a framework for running jobs in parallel.