KEMBAR78
Puppet Intro | PDF | Sudo | Computer Science
0% found this document useful (0 votes)
11 views5 pages

Puppet Intro

Uploaded by

Swami Srinivas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views5 pages

Puppet Intro

Uploaded by

Swami Srinivas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 5

Managing multiple servers

scaling up and scaling down servers based on application usage


the work velocity of developers were affected since sysadmins were taking time to
configure servers.
rolling back was a problem since there was no tool to document the different
versions of my application.

PUSH based configuration management tools: Ansible and Saltstack


PULL based configuration management tools: Puppet and chef

1 - puppet ubuntu
2 - clients (centos,ubuntu)

puppet master and clients should have entries of hosts data in /etc/hosts file
resolve them

now pupper is a javabased standalone server

apt.puppetlabs.com

download puppetlabs-release-pc1-trusty.deb

sudo dpkg -i puppetlabs-release-pc1-trusty.deb

sudo apt-get update

sudo apt-get install pupperserver

vi /etc/default/puppetserver

JAVA_ARGS - change the ram if needed

sudo service puppetserver start

puppet collections has to be installed

/opt/puppetlabs/bin/puppet

root will have direct command path entry to use puppet

/etc/puppetlabs/code/environments/production

for centos client


yum.puppetlabs.com
puppetlabs-release-pc1-el-6.noarch.rpm for centos 6

and install in the client

yum install puppet-agent

after install

ls /opt/puppetlabs/

env | grep PATH

vi /etc/puppetlabs/puppet/puppet.conf

puppet agent --test : to run puppet agent one time


in master server - puppet cert list : will list the certificates waiting for
certify

puppet cert sign centos : to certify

for second client:


apt.puppetlabs.com
puppetlabs-release-pc1-trusty.deb and install
sudo apt-get update
sudo apt-get puppet-agent

sudo su -

env| grep PATH


puppet agent --test

in master server - puppet cert list : will list the certificates waiting for
certify
puppet cert sign ubuntu : to certify

Manage a file:-
under
/etc/puppetlabs/code/environments/production/manifests
vi site.pp
node default {
file { '/etc/motd':
owner => 'root',
group => 'root',
mode => '0644',
content => " \nwelcome to your new puppets client machines\n"
}
}

node centos {
} - for node specific

puppet agent --test

creating a module:-

module is group of coding tasks


/etc/puppetlabs/code/environments/production/manifests/modules
mkdir motd
cd motd
mkdir manifests

vi init.pp
class motd {
file { '/etc/motd':
owner => 'root',
group => 'group',
mode => '0644',
content => inline_template(" the current time is <%= Time.now %> \n")
}
}
vi crabby.pp
class motd::crabby {
notify { " knife crab is the best":}
}

cd /etc/puppetlabs/code/environments/production/manifests
vi site.pp
node default {
class { 'motd':}
class { 'motd::crabby':}
}

using facter(sic):-
facter
facter system_uptime
facter osfamily
/etc/puppetlabs/code/environments/production/modules/motd/manifests

vi init.pp
class motd {
file { '/etc/motd':
owner => 'root',
group => 'group',
mode => '0644',
content => inline_template(" the current $osfamily time is <%= Time.now %> \
n")
}
}

installing packages:-
/etc/puppetlabs/code/environments/production/modules/
mkdir mystuff
cd mystuff
mkdir manifests
vi init.pp

class mystuff {
notify {" i'm installing stuff like you wanted me to sir":}
include mystuff::vim
}

vi vim.pp
class mystuff::vim{
package {'vim':
ensure => 'latest'
}
}
/etc/puppetlabs/code/environments/production/modules
cd manifests
vi site.pp
node default {
class { 'motd':}
class { 'mystuff': }
}

using conditionals and modules:-


/etc/puppetlabs/code/environments/production/modules/mystuff/manifests
vi apache.pp
class mystuff::apache{
if $osfamily == 'redhat' {
package { 'httpd':
ensure => 'latest'
}
}
elsif $osfamily == 'debian' {
package { 'apache2':
ensure => 'latest'
}
}
}
vi init.pp
inclue mystuff::apache

on client : puppet agent --test

files and file templates:-


puppet:///modules/mod-name/file.txt
.../production/modules/mod-name/files/file.txt
cd /etc/puppetlabs/code/modules
/etc/puppetlabs/code/environments/production/modules/motd/manifests
vi init.pp
class motd {
file { '/etc/motd':
owner => 'root',
group => 'group',
mode => '0644',
source => "puppet:///modules/motd/motd.txt"
}
}

cd /etc/puppetlabs/code/environments/production/modules/motd/
mkdir files
cd files
vi motd.txt
asdkf;askldf
asdf
asdfasd
fas
facter

/etc/puppetlabs/code/environments/production/modules/mystuff/manifests
vi docs.pp
class mystuff::docs {
file { '/var/www/html/index.html':
content => template('mystuff/index.html.erb')
}
}

/etc/puppetlabs/code/environments/production/modules/mystuff/templates
vi index.html.erb
<html>
<h1>
i love linux, especially at <%= Time.now %>
</h1>
<h3>
but i love <%= @osfamily %> the most
</h3>
</html>
/etc/puppetlabs/code/environments/production/modules/mystuff/manifests
vi init.pp
include mystuff::docs

Puppet Forge:-
forge.puppetlabs.com
puppet module list
puppet module search ntp
puppet module install puppetlabs-ntp
/etc/puppetlabs/code/environments/production/modules/ntp/manifests
/etc/puppetlabs/code/environments/production/manifests
vi site.pp
class {'::ntp': }
on client run puppet agent --test

tweaking agent systems:-


on client
cat /etc/default/puppet
vi /etc/puppetlabs/puppet/puppet.conf
[main]
server = puppet
runinterval = 1m (default is 30m)

puppet resource service puppet ensure=running enable=true

puppet reference manual


docs.puppetlabs.com/puppet/latest/reference

You might also like