Wilson Mar bio photo

Wilson Mar

Hello!

Calendar YouTube Github

LinkedIn

Puppet

US (English)   Norsk (Norwegian)   Español (Spanish)   Français (French)   Deutsch (German)   Italiano   Português   Estonian   اَلْعَرَبِيَّةُ (Egypt Arabic)   Napali   中文 (简体) Chinese (Simplified)   日本語 Japanese   한국어 Korean

Overview

This article currently contains my notes about installing and using Puppet.

Competitors to Puppet

Puppet is used to automate a way to ensure that all servers have consistent configuration. was created in 2005 by Luke Kanies. Commercialization began in 2011 at puppet.com.

Also in the configuration management software market:

  • SaltStack Enterprise
  • Enterprise Chef (requires Ruby skills)
  • Ansible
  • CF Engine (first relased 1993)

In 2016, Puppet is seeing customers move to Ansible. But Puppet skills are still in demand.

Puppet can do this across different versions of different operating systems! This is possible because Puppet manifest files are declarative in that they specify the configuration desired (the “what”), whereas server shell scripts are more complicated since they specify procedural (the “how”), which differ for different operating systems.

Local Installation

https://Virtualbox.org/wiki/downloads

https://www.VagrantUp.com/downloads.html

Linux installs

  1. Install an Apache web server on Ubuntu:

    sudo apt-get install apache2
    

    On Redhat:

    sudo yum install httpd
    yum repolist
    
  2. Puppet install on CentOS:

    sudo yum install puppet-agent #CentOS
    sudo apt-get install puppet-agent 
    sudo rpm -Uvh \
    https://yum.puppetlabs.com/puppetlabs-release-pc1-e1-7-noarch.rpm
    

    Puppet 4 introduced Puppet-collections to ensure that dependency packages such as heira, facter, and ruby are consistent to a given Puppet version.

    On Ubuntu, “trusty” is the code name for the 14.04 Debian repo:

    wget https://apt.puppetlabs.com/puppetlabs-release-pc1-trusty.deb
    sudo dpkg -i puppetlabs-release-pc1-trusty.deb
    sudo apt-get update
    
  3. Puppet all-in-one client install (without the -y to see dependencies):

    sudo yum install puppet-agent #CentOS
    sudo apt-get install puppet-agent #Ubuntu
    

Config

  1. Verify on any platform:

    puppet agent --version
    

    Instead of printing all values, specify specific values:

    puppet config print certname
    puppet config print { confdir rundir  ssldir  vardir  runinterval }
    

    NOTE: The default environmenttimeout is 5 minutes when a server is checked for changes.

    The runinterval default is 1800 (30 minutes).

    confdir yields where the conf directory is (changed from “puppet” in v3):

    /etc/puppetlabs/puppet
    

    vardir yields where the variable directory is (changed from v3):

    /opt/puppetlabs/puppet/cache
    
  2. PROTIP: Add in the path within your bash profile file symlinks to folder:

    <strong>/opt/puppetlabs/bin</strong>
    

    the symlinks resolve to:

    /opt/puppetlabs/puppet/bin
    

    Direct editing takes a few less microseconds to run (and faster to read) than checking every time:

    if ! echo $PATH | grep -q /opt/puppetlabs/bi ; then
       export PATH=$PATH:/opt/puppetlabs/bin
    fi
    
  3. Edit secure_path in visudo file:

    sudo visudo
    

    Add to end:

    secure_path=/sbin:/bin/:/usr/sbin:/usr/bin<strong>:/opt/puppetlabs/bin</strong>
    

Resources

  1. For an individual’s information:

    sudo puppet resource user bob
    
  2. Pipe status info about a service to a manifest file:

    sudo puppet resource service puppet > puppet-service.pp
    

    the response in the file is:

    service { 'puppet':
      ensure => 'stopped',
      enable => 'false',
    }
    
  3. Pipe the status info to a manifest file:

PROTIP: Like Ansible, Puppet configurations are idempotent (a combination of two Latin words “idem” = the same and “potent”=power), meaning that the same script runs several times will result in the same result. Something not created will be created when the job runs. Something created already will not result in a “already exists” error.

Resource declarations are text files ending in .pp. The Puppet Apply program reads such files.

They specify each node’s Type (Package, File, or Service) , Title (such as ‘ntp’), Attributes/Parameters, Provider:

node 'appserver01' {
  package { 'ntp':
    ensure => 'installed';
  }
  file { '/etc/readme.txt':
    ensure  => 'present',
    content => "This file.",
  }
  file { 'Readme':
    ensure  => 'present',
    content => "This file.",
    path => "/etc/readme.txt",
  }
  service { 'ntpd':
    ensure  => 'running',
    enable  => true,
  }
}
  1. List available resources:

    sudo puppet describe --list
    

Start service

   systemctl start puppet

Then:

   sudo puppet apply puppet-service.pp

Manifests Declaration

Text files ending in .pp are Puppet manifest declarations read by the Puppet Apply program.

  1. Create a “hello world” manifest

  2. To validate:

    sudo puppet parser validate puppet-service.pp
    
  3. To run dynamically, instead of a .pp file:

    sudo puppet apply -e "notify { 'Hello world!' : }"
    

    Example responses are rather verbose:

    Notice: Compiled catalog for centos7 in environment production in 0.05 seconds
    Notice: Hello world!
    Notice: /Stage[main]/Main/Notify[Hello world!]/message: defined 'message' as 'Hellow world!'
    Notice: Applied catalog in 0.05 seconds
    
  4. To view the last file:

    cat !$
    

    PROTIP: See Puppet’s Style Guide

Puppet Module

  1. Puppet modules in module forge.

  2. Install a custom module:

    sudo puppet module install theurbanpenguin/puppet_vim
    include puppet_vim
    
  3. What modules have been installed?

    sudo puppet module list
    

    These are storred in:

    /etc/puppetlabs/code/environments/production/modules
    

PuppetMaster Server

A PuppetMaster server, a Ruby on Rails app running on Linux (Centos).

When working in the cloud, many are moving away from PuppetMaster servers but still using Puppet server definition files.

Each node runs an agent which can be Unix (BSD and Mac OSX), even Windows.

Nodes connect to the PM over port 8140.

The master creates and maintains a catalog of nodes.

The facter collects facts from each node (OS, CPU, network, block devices, etc.).

Resource Declaration

More Learning Resources

Ben Piper (@_benpiper) in

  • Puppet Fundamentals for System Administrators for Beginners Feb 11, 2015 5h 31m provides https://github.com/benpiper/puppet-fundamentals-lab to show how to use Git to manage Puppet configurations which bring up a Puppet Master on CentOs controlling PHP-based MediaWiki website based on Apache and MySQL on both CentOS 6.5 and Ubuntu 14.04.1 LTS. Each servers requires 2 GB RAM and 20 GB disks. Additionally, a winadmin 2008 R2 server for Admin. is stood up using 40 GB.

Andrew Mallett (from the UK at @theurbanpenguin) created in-depth video tutorials using CentOS 7.2 and Ubuntu 14.04 KVMs, which both use the same systemd upstart service manager commands.

Will Button

More on IoT

This is one of a series on IoT:

  1. IoT Acronymns and Abbreviations on Quizlet

  2. IoT Home Assistant system

  3. IoT Apprentice school curriculum
  4. IoT use cases
  5. IoT reminders prevent dead mobile battery
  6. IoT barn feeder

  7. IoT text to speech synthesis
  8. IoT AWS button
  9. Intel IoT
  10. IoT Raspberry hardware
  11. IoT Raspberry installation

  12. IoT Clouds
  13. Samsung IoT Cloud

NOTE: Pages about GE’s Predix have been removed.