Book Image

Puppet 5 Beginner's Guide - Third Edition

By : John Arundel
Book Image

Puppet 5 Beginner's Guide - Third Edition

By: John Arundel

Overview of this book

Puppet 5 Beginner’s Guide, Third Edition gets you up and running with the very latest features of Puppet 5, including Docker containers, Hiera data, and Amazon AWS cloud orchestration. Go from beginner to confident Puppet user with a series of clear, practical examples to help you manage every aspect of your server setup. Whether you’re a developer, a system administrator, or you are simply curious about Puppet, you’ll learn Puppet skills that you can put into practice right away. With practical steps giving you the key concepts you need, this book teaches you how to install packages and config files, create users, set up scheduled jobs, provision cloud instances, build containers, and so much more. Every example in this book deals with something real and practical that you’re likely to need in your work, and you’ll see the complete Puppet code that makes it happen, along with step-by-step instructions for what to type and what output you’ll see. All the examples are available in a GitHub repo for you to download and adapt for your own server setup.
Table of Contents (21 chapters)
Puppet 5 Beginner's Guide Third Edition
Credits
About the Author
Acknowledgments
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface
Index

Index

A

  • Active Directory (AD) server / The advantages of managing resources with Hiera data
  • Amazon AWS account
    • setting up / Setting up an Amazon AWS account
    • creating / Creating an AWS account
    • IAM policy, creating / Creating an IAM policy
    • IAM user, creating / Creating an IAM user
    • AWS credentials, storing / Storing your AWS credentials
  • Amazon Machine Image (AMI)
    • selecting / Choosing an Amazon Machine Image (AMI)
  • arithmetic expressions / Introducing expressions
  • arrays
    • creating / Creating arrays
    • of resources, declaring / Declaring arrays of resources
  • arrays, Hiera / Arrays
  • attribute splat operator / Setting resource attributes from a hash, Provisioning AWS resources from Hiera data
  • AWS credentials
    • storing / Storing your AWS credentials
  • AWS resources
    • provisioning, from Hiera data / Provisioning AWS resources from Hiera data
    • Hiera data iterating over, to create resources / Iterating over Hiera data to create resources
    • unused resources, cleaning up / Cleaning up unused resources
  • AWS SDK gem
    • installing / Installing the AWS SDK gem

B

  • bare word / Using Booleans
  • batch jobs / Cron resources
  • Boolean expressions / Introducing expressions
  • Booleans
    • using / Using Booleans
  • Boolean values, Hiera / Boolean values
  • bootstrap process / The bootstrap process
  • branching / Branching

C

  • case statements
    • options, selecting / Choosing options with case statements
  • catalog / Distributing Puppet manifests
  • classes
    • about / Classes
    • class keyword / The class keyword
    • parameters, declaring / Declaring parameters to classes
    • automatic parameter lookup, from Hiera data / Automatic parameter lookup from Hiera data
    / Classes
  • classes, managing with Hiera
    • about / Managing classes with Hiera
    • include, using with lookup() / Using include with lookup()
    • common and per-node classes / Common and per-node classes
  • cloud
    • about / Introducing the cloud
    • provisioning, automating / Automating cloud provisioning
    • CloudFormation, using / Using CloudFormation
    • Terraform, using / Using Terraform
    • Puppet, using / Using Puppet
  • CloudFormation
    • using / Using CloudFormation
  • commit message / Tracking changes, Making your first commit
  • comparison operators / Meeting Puppet's comparison operators
  • conditional expressions
    • using / Using conditional expressions
  • conditional statements / Conditional statements in templates
  • Configuration management (CM)
    • about / Configuration management tools
  • containers
    • about / Understanding containers, Introducing the container
    • deployment issues / The deployment problem
    • deployment, options / Options for deployment
    • Docker role / What Docker does for containers
    • managing, with Puppet / Managing containers with Puppet
    • connecting / Connecting containers
    • orchestration / Container orchestration
    • orchestration, tools / What orchestration tools are available?
    • Puppet, running / Running Puppet inside containers
    • mini VMs / Are containers mini VMs or single processes?
    • single processes / Are containers mini VMs or single processes?
    • configuring, with Puppet / Configuring containers with Puppet
    • Puppet, need for / Containers need Puppet too
  • control repo / The control repo
  • cron resources
    • about / Cron resources
    • attributes / Attributes of the cron resource
    • cron jobs, randomizing / Randomizing cron jobs
    • cron jobs, removing / Removing cron jobs
  • cron table / Cron resources
  • custom VPCs and subnets
    • managing / Managing custom VPCs and subnets
    • instance, creating / Creating an instance in a custom VPC
    • ec2_vpc resource / The ec2_vpc resource
    • ec2_vpc_internet_gateway resource / The ec2_vpc_internet_gateway resource
    • ec2_vpc_routetable resource / The ec2_vpc_routetable resource
    • ec2_vpc_subnet resource / The ec2_vpc_subnet resource
    • other AWS resource types / Other AWS resource types

D

  • declarative style / What is Puppet?
  • deep merge behavior / Merge behaviors
  • defined resource type
    • about / Defined resource types
    • Type aliases / Type aliases
  • demo repo
    • getting / Getting the demo repo
    • copying / Copying the repo
    • about / Understanding the demo repo
    • control repo / The control repo
    • module management / Module management
    • classes / Classes
    • roles / Roles
    • profiles / Profiles
    • users and access control / Users and access control
    • SSH configuration / SSH configuration
    • Sudoers configuration / Sudoers configuration
    • time zone and clock synchronization / Time zone and clock synchronization
    • Puppet configuration / Puppet configuration
    • adapting, for own use / Adapting the repo for your own use
    • users, configuring / Configuring users
    • per-node data files, adding / Adding per-node data files and role classes
    • role classes / Adding per-node data files and role classes
    • bootstrap credentials, modifying / Modifying the bootstrap credentials
  • dictionary / Hashes
  • Docker
    • deployment with / Deployment with Docker
    • containers, building / Building Docker containers
    • layered filesystem / The layered filesystem
    • containers, mnanaging with Puppet / Managing containers with Puppet
    • managing, with Puppet / Managing Docker with Puppet
    • installing / Installing Docker
    • container, running / Running a Docker container
    • container, stopping / Stopping a container
    • container multiple instances, running / Running multiple instances of a container
  • Dockerfiles
    • used, for building images / Building images from Dockerfiles
    • managing / Managing Dockerfiles
  • Docker images
    • managing / Managing Docker images
    • building, from Dockerfiles / Building images from Dockerfiles
    • Dockerfiles, managing / Managing Dockerfiles
  • docker volumes / Docker volumes
  • dynamic containers
    • building / Building dynamic containers
    • configuring, with templates / Configuring containers with templates
    • self-configuring containers / Self-configuring containers
    • persistent storage / Persistent storage for containers
    • host-mounted volumes / Host-mounted volumes
    • docker volumes / Docker volumes

E

  • each function
    • using / Using the each function
  • EC2 Container Service (ECS) / Other AWS resource types
  • EC2 instances
    • creating, with Puppet / Creating EC2 instances with Puppet
    • Amazon Machine Image (AMI), selecting / Choosing an Amazon Machine Image (AMI)
    • creating / Creating the EC2 instance
    • accessing / Accessing your EC2 instance
    • VPCs / VPCs, subnets, and security groups
    • subnets / VPCs, subnets, and security groups
    • security groups / VPCs, subnets, and security groups
    • ec2_securitygroup resource / The ec2_securitygroup resource
    • ec2_instance resource / The ec2_instance resource
  • ec2_instance resource / The ec2_instance resource
  • ec2_securitygroup resource / The ec2_securitygroup resource
  • ec2_vpc_internet_gateway resource / The ec2_vpc_internet_gateway resource
  • ec2_vpc_routetable resource / The ec2_vpc_routetable resource
  • ec2_vpc_subnet resource / The ec2_vpc_subnet resource
  • Elastic Load Balancing (ELB) / The ec2_vpc_internet_gateway resource
  • ensure_packages
    • using / Using ensure_packages
    • used, for installing packages / Safely installing packages with ensure_packages
  • ERB template / Legacy ERB templates
  • exec resources
    • about / Exec resources
    • manual interaction, automating / Automating manual interaction
    • attributes / Attributes of the exec resource
    • user attribute / The user attribute
    • unless attribute / The onlyif and unless attributes
    • onlyif attribute / The onlyif and unless attributes
    • onlyif attributes / The onlyif and unless attributes
    • refreshonly attribute / The refreshonly attribute
    • logoutput attribute / The logoutput attribute
    • timeout attribute / The timeout attribute
    • misuse, avoiding / How not to misuse exec resources
  • executable facts
    • creating / Creating executable facts
  • expressions
    • about / Introducing expressions
    • comparison operators, meeting / Meeting Puppet's comparison operators
    • regular expressions / Introducing regular expressions
    • conditional expressions, using / Using conditional expressions
    • decisions, making with if statements / Making decisions with if statements
    • options, selecting with case statements / Choosing options with case statements
  • external facts
    • providing / Providing external facts

F

  • facter command
    • running / Running the facter command
  • facts
    • finding / Finding out facts
    • hash, using / Using the facts hash
    • facter command, running / Running the facter command
    • hashes of facts, accessing / Accessing hashes of facts
    • referencing, in expressions / Referencing facts in expressions
    • memory facts, using / Using memory facts
    • networking facts, discovering / Discovering networking facts
    • external facts, providing / Providing external facts
    • executable facts, creating / Creating executable facts
  • facts hash
    • using / Using the facts hash
  • files
    • about / Files
    • path attribute / The path attribute
    • whole files, managing / Managing whole files
    • ownership / Ownership
    • permissions / Permissions
    • directories / Directories
    • trees of files / Trees of files
    • symbolic links / Symbolic links
  • fully qualified domain name (FQDN) / Discovering networking facts

G

  • generate-puppetfile
    • used, for managing directories / Managing dependencies with generate-puppetfile
  • Git repo
    • creating / Creating a Git repo
    • first commit, creating / Making your first commit
    • committing / How often should I commit?
    • branching / Branching
  • GnuPG
    • setting up / Setting up GnuPG
  • Google Compute Engine (GCE) / Using other distributions and providers

H

  • hashes
    • about / Understanding hashes
  • hashes, Hiera / Hashes
  • hashes of facts
    • accessing / Accessing hashes of facts
  • hash merge behavior / Merge behaviors
  • hasrestart attribute / The hasrestart and restart attributes
  • hasstatus attribute / The hasstatus attribute
  • Hiera
    • about / Why Hiera?
    • data maintenance / Data needs to be maintained
    • nodes / Settings depend on nodes
    • operating systems / Operating systems differ
    • way / The Hiera way
    • setting up / Setting up Hiera
    • troubleshooting / Troubleshooting Hiera
    • querying / Querying Hiera
  • Hiera, querying
    • about / Querying Hiera
    • typed lookups / Typed lookups
  • Hiera data
    • adding, to Puppet repo / Adding Hiera data to your Puppet repo
    • resources, creating with / Creating resources with Hiera data
    • resources, building from Hiera arrays / Building resources from Hiera arrays
    • resources, building from Hiera hashes / Building resources from Hiera hashes
    • resources managing with, advantages for / The advantages of managing resources with Hiera data
    • automatic parameter lookup / Automatic parameter lookup from Hiera data
    • range parameters / Range parameters
    • used, for managing classes / Managing classes with Hiera
  • Hiera data, interpolation
    • about / Interpolation in Hiera data
    • lookup(), using / Using lookup()
    • alias(), using / Using alias()
    • literal(), using / Using literal()
  • Hiera data, types
    • about / Types of Hiera data
    • single values / Single values
    • Boolean values / Boolean values
    • arrays / Arrays
    • hashes / Hashes
  • hierarchy, Hiera
    • about / The hierarchy
    • multiple values, dealing with / Dealing with multiple values
    • behaviors, merging / Merge behaviors
    • facts, data sources based / Data sources based on facts
    • data characteristics / What belongs in Hiera?
  • host-mounted volume / Host-mounted volumes

I

  • IAM policy
    • creating / Creating an IAM policy
  • IAM user
    • creating / Creating an IAM user
  • idempotent / How not to misuse exec resources
  • inline templates / Inline templates
  • iteration
    • about / Iterating over arrays
    • each function, using / Using the each function
    • over hashes / Iterating over hashes

L

  • linked resource
    • notifying / Notifying a linked resource
  • logoutput attribute / The logoutput attribute

M

  • memory facts
    • using / Using memory facts
  • merge behavior / Merge behaviors
  • modules
    • using, in manifests / Using modules in your manifests
    • puppetlabs/mysql, using / Using puppetlabs/mysql
    • puppetlabs/apache, using / Using puppetlabs/apache
    • puppet/archive, using / Using puppet/archive
    • writing / Writing your own modules
    • repo, creating / Creating a repo for your module
    • code, writing / Writing the module code
    • metadata, creating / Creating and validating the module metadata
    • metadata, validating / Creating and validating the module metadata
    • tagging / Tagging your module
    • installing / Installing your module
    • applying / Applying your module
    • complex modules / More complex modules
    • uploading, to Puppet Forge / Uploading modules to Puppet Forge

N

  • networking facts
    • about / Discovering networking facts
  • node
    • Bootstrapping / Bootstrapping a new node
    • other distributions and providers, using / Using other distributions and providers

O

  • onlyif attribute / The onlyif and unless attributes
  • orchestration
    • about / What is orchestration?

P

  • packages
    • managing / Managing packages
    • manifest, applying to Puppet / How Puppet applies the manifest
    • resources, querying with puppet resource / Querying resources with the puppet resource
    • about / Packages
    • uninstalling / Uninstalling packages
    • specific versions, installing / Installing specific versions
    • latest version, installing / Installing the latest version
    • Ruby gems, installing / Installing Ruby gems
    • gems, installing in Puppets context / Installing gems in Puppet's context
    • ensure_packages, using / Using ensure_packages
  • parameter data types
    • about / Parameter data types
    • available / Available data types
    • content type parameters / Content type parameters
    • range parameters / Range parameters
    • flexible data types / Flexible data types
  • parameters
    • declaring, to classes / Declaring parameters to classes
  • pattern attribute / The pattern attribute
  • physical or cloud nodes
    • Bootstrapping / Bootstrapping physical or cloud nodes
  • procedural style / What is Puppet?
  • profiles
    • about / Profiles
    / Profiles
  • pry debugger / The pry debugger
  • Puppet
    • need for / Why do we need Puppet anyway?
    • configuration, synchronizing / Keeping the configuration synchronized
    • changes, repeating across servers / Repeating changes across many servers
    • documentation, self-updating / Self-updating documentation
    • version control and history / Version control and history
    • shell scripts / Why not just write shell scripts?
    • containers / Why not just use containers?
    • serverless / Why not just use serverless?
    • about / What is Puppet?
    • resources / Resources and attributes
    • attributes / Resources and attributes
    • architectures / Puppet architectures
    • preparing for / Getting ready for Puppet
    • repo, downloading / Installing Git and downloading the repo
    • Git, installing / Installing Git and downloading the repo
    • VirtualBox, installing / Installing VirtualBox and Vagrant
    • Vagrant, installing / Installing VirtualBox and Vagrant
    • Vagrant VM, running / Running your Vagrant VM
    • Vagrant, troubleshooting / Troubleshooting Vagrant
  • Puppet, architecture
    • agent/master architecture / Puppet architectures
    • stand-alone Puppet or masterless / Puppet architectures
  • Puppetfile
    • about / Understanding the Puppetfile
  • Puppet Forge
    • modules, using / Using Puppet Forge modules
    • about / What is the Puppet Forge?
    • modules, finding / Finding the module you need
    • 10k, using / Using r10k
    • dependencies, managing generate-puppetfile used / Managing dependencies with generate-puppetfile
    • modules, uploading / Uploading modules to Puppet Forge
  • puppetlabs/aws module
    • about / Getting ready to use puppetlabs/aws
    • key pair, creating / Creating a key pair
    • installing / Installing the puppetlabs/aws module
    • AWS SDK gem, installing / Installing the AWS SDK gem
  • Puppet manifest
    • about / Hello, Puppet – your first Puppet manifest
    • code / Understanding the code
    • existing files,modifying / Modifying existing files
    • dry-running / Dry-running Puppet
    • applying / How Puppet applies the manifest
    • file, creating / Creating a file of your own
  • Puppet manifests
    • distributing / Distributing Puppet manifests
    • GitHub account and project, creating / Creating a GitHub account and project
    • repo, pushing to GitHub / Pushing your repo to GitHub
    • repo, cloning / Cloning the repo
  • Puppet repo
    • Hiera data, adding / Adding Hiera data to your Puppet repo
  • Puppet runs
    • changes, applying / Fetching and applying changes automatically
    • changes, fetching / Fetching and applying changes automatically
    • running, manifests writing for / Writing a manifest to set up regular Puppet runs
    • run-puppet manifest, applying / Applying the run-puppet manifest
    • run-puppet script / The run-puppet script
    • automatic Puppet runs, testing / Testing automatic Puppet runs
    • multiple nodes, managing / Managing multiple nodes

R

  • r10k
    • using / Using r10k
  • refreshonly attribute / The refreshonly attribute
  • regular expressions / Introducing regular expressions
  • repo
    • about / Sharing code
    • pushing, to GitHub / Pushing your repo to GitHub
    • cloning / Cloning the repo
  • repository / Sharing code
  • resource attributes
    • setting, from hash / Setting resource attributes from a hash
  • restart attribute / The hasrestart and restart attributes
  • roles
    • about / Roles and profiles, Roles
    / Roles
  • Ruby gems
    • installing / Installing Ruby gems
    • installing, in Puppet's context / Installing gems in Puppet's context
  • run-puppet script / The run-puppet script

S

  • secret data
    • managing / Managing secret data
    • GnuPG, setting up / Setting up GnuPG
    • encrypted Hiera source, adding / Adding an encrypted Hiera source
    • encrypted secret, creating / Creating an encrypted secret
    • decrypting, by Hiera / How Hiera decrypts secrets
    • encrypted secrets, editing / Editing or adding encrypted secrets
    • encrypted secrets, adding / Editing or adding encrypted secrets
    • decryption key, distributing / Distributing the decryption key
  • services
    • about / Services, Services
    • resources, with puppet describe / Getting help on resources with puppet describe
    • package-file-service pattern / The package-file-service pattern
    • linked resource, notifying / Notifying a linked resource
    • resource ordering, require used / Resource ordering with require
    • hasstatus attribute / The hasstatus attribute
    • pattern attribute / The pattern attribute
    • hasrestart and restart attributes / The hasrestart and restart attributes
  • shallow merge / Merge behaviors
  • single values, Hiera / Single values
  • SSH configuration / SSH configuration
  • standard library
    • about / Exploring the standard library
    • packages installing safely, ensure_packages used / Safely installing packages with ensure_packages
    • files modifying, file_line used / Modifying files in place with file_line
    • useful functions, using / Introducing some other useful functions
    • pry debugger / The pry debugger
  • Sudoers configuration / Sudoers configuration
  • symbolic link / Symbolic links
  • symlink / Symbolic links

T

  • templates
    • about / What are templates?
    • dynamic data problem / The dynamic data problem
    • syntax / Puppet template syntax
    • using, in manifests / Using templates in your manifests
    • template files, referencing / Referencing template files
    • inline templates / Inline templates
    • tags / Template tags
    • computations / Computations in templates
    • conditional statements / Conditional statements in templates
    • iteration / Iteration in templates
  • templates, iteration
    • about / Iteration in templates
    • over Facter data / Iterating over Facter data
    • over structured facts / Iterating over structured facts
    • over Hiera data / Iterating over Hiera data
    • working with / Working with templates
    • parameters, passing / Passing parameters to templates
    • template syntax, validating / Validating template syntax
    • templates, rendering on command line / Rendering templates on the command line
    • Legacy ERB templates / Legacy ERB templates
  • Terraform
    • using / Using Terraform
  • timeout attribute / The timeout attribute
  • type aliases / Type aliases

U

  • unless attribute / The onlyif and unless attributes
  • user attribute / The user attribute
  • users
    • about / Users
    • creating / Creating users
    • resource / The user resource
    • group resource / The group resource
    • SSH keys, managing / Managing SSH keys
    • removing / Removing users

V

  • Vagrant
    • troubleshooting / Troubleshooting Vagrant
  • Vagrant VM
    • running / Running your Vagrant VM
    • Bootstrapping / Bootstrapping a Vagrant VM
  • variables
    • about / Introducing variables
    • Booleans, using / Using Booleans
    • interpolating, in strings / Interpolating variables in strings
    • arrays, creating / Creating arrays
    • arrays of resources, declaring / Declaring arrays of resources
    • hashes / Understanding hashes
    • resource attributes, setting from hash / Setting resource attributes from a hash
  • version control
    • about / What is version control?
    • changes, tracking / Tracking changes
    • code, sharing / Sharing code
  • virtualization / Introducing the cloud

Y

  • YAML Aint Markup Language (YAML), / Types of Hiera data