Sie sind auf Seite 1von 24

Objectives

After this chapter you should be able to:


Describe the Puppet
Puppet Uses
Puppet Master and Puppet Agent Setup
Puppet Classes Management
Puppet Modules Management

What is Puppet?

Puppet is a declarative, model-based approach to IT automation, helping


you manage infrastructure throughout its lifecycle, from provisioning and
configuration to orchestration and reporting.

How we can obtain it?

Puppet is available in open source and commercial


software.

Puppet Opensource and Enterprise


Puppet Opensource
http://puppetlabs.com/puppet/puppet-open-source
Puppet Enterprise
https://puppetlabs.com/puppet/puppet-enterprise

Installation of Puppet
Installing EPEL Repositories
RHEL 5:
# rpm -ivh http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-54.noarch.rpm

RHEL 6:
# rpm ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-68.noarch.rpm

Installing Puppet Labs Repositories


RHEL 5:
# rpm -ivh http://yum.puppetlabs.com/el/5/products/x86_64/puppetlabs-release-57.noarch.rpm

RHEL 6:
# rpm -ivh http://yum.puppetlabs.com/el/6/products/x86_64/puppetlabs-release-67.noarch.rpm

Puppet Installation Cont


Puppet master Machine:
master# yum install puppet puppet-server facter
Puppet agent Machine:
agent # yum install puppet facter
Verify the puppet version:
# puppet - -version

Installing on Debian and Ubuntu


$
$
$
$
$

cd /tmp
wget http://apt.puppetlabs.com/puppetlabs-release-precise.deb
sudo dpkg -I puppetlabs-release-precise.deb
sudo apt-get update
sudo apt-get install puppet puppetmaster facter

On Agent:
$ sudo apt-get install puppet facter
Verify the puppet version:
$ puppet --version

Installing on Microsoft Windows


Download the latest open source MSI from :
http://downloads.puppetlabs.com/windows/

Configuration of Puppet
Default file is :
/etc/puppet/puppet.conf
We Can generate the puppet server configuration file.
# cd /etc/puppet/
# puppet master --genconfig > puppet.conf

The Site.pp file

Puppet Main manifests file:


# cat /etc/puppet/manifests/site.pp

Firewall Configuration
Runs on TCP port 8140
Iptables rule for puppet:
# iptables -A INPUT -p tcp -m state --state NEW --dport
8140 -j ACCEPT

Daemon of Puppet
# service puppetmaster start
We can start puppet manually at initial.
# puppet master --verbose --no-daemonize

Agent Setup
# puppet agent --test --server=master.example.com
Also We can specify the server name in config file
# /etc/puppet/puppet.conf
[agent]
server=puppet.pro-puppet.com

Completing the Connection


master# puppet cert list
master# puppet cert sign node1.example.com
master# puppet cert sign all

Auto signing of agents


Master# echo '*' > /etc/puppet/autosign.conf
Value need to add in config file.
autosign = true

Configuration Item
Nodes: Specifies the configuration of each agent
Resources: Individual configuration items
Files: Physical files you can serve out to your agents
Templates: Template files that you can use to populate
files
Classes: Collections of resources

Node Definition
Anode definitionornode statementis a block of Puppet code
that will only be included in one nodes catalog. This feature
allows you to assign specific configurations to specific nodes.
Step-1:
How to use it?
# /etc/puppet/manifests/nodes.pp
node agent.example.com' {
include apache
}
Or can use regular expressions:
node /^www\d+$/ {
include common
}

Inheritance of node
node 'common' {
$ntpserver = 'time.example.com'
include common
}
node 'www1.example.com' inherits 'common' {
include ntp
include apache
include squid
}

Resources
Imagine a systems configuration as a collection of many independent atomic
units.
A user account
A specific file
A directory of files
A software package
A running service
A scheduled cron job
An invocation of a shell command, when certain conditions are met
Any single resource is very similar to a group of related resources:
Every file has a path and an owner
Every user has a name, a UID, and a group

Anatomy of a Resource
user { leone':
ensure => present,
uid => '507',
gid => 'admin',
shell => '/bin/zsh',
home => '/home/leone',
managehome => true,
}

Modules and Classes


Classes:
Classes are named blocks of Puppet code, which can be created in
one place and invoked elsewhere.
Defining:a class makes it available by name, but doesnt
automatically evaluate the code inside it.
Declaring:a class evaluates the code in the class, and applies all
of its resources.
Class can done with Class Keyword.

Defining a Class
class ntp {
case $operatingsystem {
centos, redhat: {
$service_name = 'ntpd'
$conf_file = 'ntp.conf.el'
}
debian, ubuntu: {
$service_name = 'ntp'
$conf_file = 'ntp.conf.debian'
}
}

Modules
To help us, split up our manifests into an easier to
understand structure, Puppet usesmodulesand
themodule autoloader.
Modules are just directories with files, arranged in a
specific, predictable structure. The manifest files within
a module have to obey certain naming restrictions.
This set of directories is known as modulepath in
settings

Module Structure
A module is a directory.
The modules name must be the name of the directory.
It contains of manifests directory, which can contain any
number of .pp files.
The manifests directory should always contain of init.pp
file
This file must contain a single class definition. The
classs name must be the same as the modules name.

Das könnte Ihnen auch gefallen