Beruflich Dokumente
Kultur Dokumente
What is Puppet?
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
RHEL 6:
# rpm -ivh http://yum.puppetlabs.com/el/6/products/x86_64/puppetlabs-release-67.noarch.rpm
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
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
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
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,
}
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.