hamidgholami / puppet_lab

Multiple code examples and scenarios regardong Puppet

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Learning Puppet

Twitter Follow GitHub Follow Linkedin Badge

What is Puppet?

  • A Configuration Management Tool
  • A framework for Systems Automation
  • A Declarative Domain Specific Language (DSL)
  • An OpenSource software in written Ruby
  • Works on Linux, Unix (Solaris, AIX, *BSD), MacOS, Windows (Supported Platforms)

Reference

Software related to Puppet

  • Facter - Complementary tool to retrieve system's data
  • MCollective - Infrastructure Orchestration framework
  • Hiera - Key-value lookup tool where Puppet data can be placed
  • PuppetDB - Stores all the data generated by Puppet
  • Puppet DashBoard - A Puppet Web frontend and External Node Classifier (ENC)
  • The Foreman - A well-known third party provisioning tool and Puppet ENC
  • Geppetto - A Puppet IDE based on Eclipse

Installation

  • Debian, Ubuntu

    wget https://apt.puppet.com/puppet7-release-focal.deb && \
    sudo dpkg -i puppet7-release-focal.deb && \
    sudo apt update
    sudo apt install puppet-agent   # On Client (Nodes)
    sudo apt install puppetserver   # On Server (Master)
  • RedHat, CentOS

    # this example is for RHEL8
    sudo rpm -Uvh https://yum.puppet.com/puppet7-release-el-8.noarch.rpm
    sudo yum install puppet-agent   # On Client (Nodes)
    sudo yum install puppetserver   # On Server (Master)

Puppet Language

  • A Declarative Domain Specific Language (DSL)
  • It defines STATES (Not procedures)
  • Puppet code is written in manifests (files with .pp extension)
  • In the code we declare resources that affect elements of the system (files, packages, services ...)
  • Resources are grouped in classes which may expose parameters that affect their behavior.
  • Classes and configuration files are organized in modules.
  • Consult the official glossary to give the correct meaning to Puppet terms

Nodes Classification

  • When clients connect, the Puppet Master generates a catalog with the list of of the resources that clients have to apply locally.

  • The Puppet Master has to classify nodes and define for each of them:

    • The classes to include
    • The parameters to pass
    • The Puppet environment to use
  • The catalog is generated by the Master according to the logic of our Puppet code and data.

  • In our code we can define our variables and use other ones that may come from different sources:

    • facts generated directly by the client.
    • parameters obtained from node's classification.
    • Puppet internal variables.

Resource Types

  • Resource Types are single units of configuration composed by:
    • A type (package, service, file, user, mount, exec ...)
    • A title (how is called and referred)
    • Zero or more arguments.
      type { 'title':
        argument  => value,
        other_arg => value,
      }
      
      Example for a file resource type:
      file { 'motd':
        path     => '/etc/motd',
        content  => 'Let's learning Puppet :)'
      }

Resource Type refrence

  • From the shell the command line interface:
    puppet describe file
  • For the full list of available descriptions try:
    puppet describe --list
  • Puppet code for the list of native resource types:
    ls $(facter rubysitedir)/puppet/type

Simple sample of resources

  • Installation of OpenSSH package
    package { 'openssh':
       ensure   => present,
    }
  • Creation of /etc/motd file
    file { 'motd':
       path   => '/etc/motd',
    }
  • Start of http service
    service { 'httpd':
        ensure => running,
        enable => true,
    }

TO DO

Preview
  • Complete Puppet learning in README.md file
  • Vagrantfile for creating Puppet server-client environment.
  • docker-compose.yml for creating puppet server instance
  • Configuring puppetdb and fireman
  • Creating a secanrio with this environment and Puppet. (preferably install k8s-lab through Puppet)

About

Multiple code examples and scenarios regardong Puppet

License:Apache License 2.0


Languages

Language:Shell 100.0%