Puppet 5 Beginner's Guide - Third Edition

Book description

Puppet 5 Beginner’s Guide, Third Edition is a practical guide that gets you up and running with the very latest features of Puppet 5.

About This Book

  • Develop skills to run Puppet 5 on single or multiple servers without hiccups
  • Use Puppet to create and manage cloud resources such as Amazon EC2 instances
  • Take full advantage of powerful new features of Puppet including loops, data types, Hiera integration, and container management

Who This Book Is For

Puppet 5 Beginner’s Guide, Third Edition is designed for those who are new to Puppet, including system administrators and developers who are looking to manage computer server systems for configuration management. No prior programming or system administration experience is assumed.

What You Will Learn

  • Understand the latest Puppet 5 features
  • Install and set up Puppet and discover the latest and most advanced features
  • Configure, build, and run containers in production using Puppet’s industry-leading Docker support
  • Deploy configuration files and templates at super-fast speeds and manage user accounts and access control
  • Automate your IT infrastructure
  • Use the latest features in Puppet 5 onward and its official modules
  • Manage clouds, containers, and orchestration
  • Get to know the best practices to make Puppet more reliable and increase its performance

In Detail

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.

Style and approach

This tutorial is packed with quick step-by-step instructions that are immediately applicable for beginners. This is an easy-to-read guide, to learn Puppet from scratch, that explains simply and clearly all you need to know to use this essential IT power tool, while applying these solutions to real-world scenarios.

Table of contents

  1. Puppet 5 Beginner's Guide Third Edition
    1. Table of Contents
    2. Puppet 5 Beginner's Guide Third Edition
    3. Credits
    4. About the Author
    5. Acknowledgments
    6. About the Reviewer
    7. www.PacktPub.com
      1. eBooks, discount offers, and more
        1. Why subscribe?
    8. Customer Feedback
    9. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Downloading the example code
        2. Errata
        3. Piracy
        4. Questions
    10. 1. Getting started with Puppet
      1. Why do we need Puppet anyway?
        1. Keeping the configuration synchronized
        2. Repeating changes across many servers
        3. Self-updating documentation
        4. Version control and history
        5. Why not just write shell scripts?
        6. Why not just use containers?
        7. Why not just use serverless?
      2. Configuration management tools
      3. What is Puppet?
        1. Resources and attributes
        2. Puppet architectures
      4. Getting ready for Puppet
        1. Installing Git and downloading the repo
        2. Installing VirtualBox and Vagrant
        3. Running your Vagrant VM
        4. Troubleshooting Vagrant
      5. Summary
    11. 2. Creating your first manifests
      1. Hello, Puppet – your first Puppet manifest
        1. Understanding the code
        2. Modifying existing files
        3. Dry-running Puppet
        4. How Puppet applies the manifest
        5. Creating a file of your own
      2. Managing packages
        1. How Puppet applies the manifest
        2. Exercise
        3. Querying resources with the puppet resource
      3. Services
        1. Getting help on resources with puppet describe
        2. The package-file-service pattern
        3. Notifying a linked resource
        4. Resource ordering with require
      4. Summary
    12. 3. Managing your Puppet code with Git
      1. What is version control?
        1. Tracking changes
        2. Sharing code
      2. Creating a Git repo
        1. Making your first commit
        2. How often should I commit?
        3. Branching
      3. Distributing Puppet manifests
        1. Creating a GitHub account and project
        2. Pushing your repo to GitHub
        3. Cloning the repo
      4. Fetching and applying changes automatically
        1. Writing a manifest to set up regular Puppet runs
        2. Applying the run-puppet manifest
        3. The run-puppet script
        4. Testing automatic Puppet runs
        5. Managing multiple nodes
      5. Summary
    13. 4. Understanding Puppet resources
      1. Files
        1. The path attribute
        2. Managing whole files
        3. Ownership
        4. Permissions
        5. Directories
        6. Trees of files
        7. Symbolic links
      2. Packages
        1. Uninstalling packages
        2. Installing specific versions
        3. Installing the latest version
        4. Installing Ruby gems
        5. Installing gems in Puppet's context
        6. Using ensure_packages
      3. Services
        1. The hasstatus attribute
        2. The pattern attribute
        3. The hasrestart and restart attributes
      4. Users
        1. Creating users
        2. The user resource
        3. The group resource
        4. Managing SSH keys
        5. Removing users
      5. Cron resources
        1. Attributes of the cron resource
        2. Randomizing cron jobs
        3. Removing cron jobs
      6. Exec resources
        1. Automating manual interaction
        2. Attributes of the exec resource
        3. The user attribute
        4. The onlyif and unless attributes
        5. The refreshonly attribute
        6. The logoutput attribute
        7. The timeout attribute
        8. How not to misuse exec resources
      7. Summary
    14. 5. Variables, expressions, and facts
      1. Introducing variables
        1. Using Booleans
        2. Interpolating variables in strings
        3. Creating arrays
        4. Declaring arrays of resources
        5. Understanding hashes
        6. Setting resource attributes from a hash
      2. Introducing expressions
        1. Meeting Puppet's comparison operators
        2. Introducing regular expressions
        3. Using conditional expressions
        4. Making decisions with if statements
        5. Choosing options with case statements
      3. Finding out facts
        1. Using the facts hash
        2. Running the facter command
        3. Accessing hashes of facts
        4. Referencing facts in expressions
        5. Using memory facts
        6. Discovering networking facts
        7. Providing external facts
        8. Creating executable facts
      4. Iterating over arrays
        1. Using the each function
        2. Iterating over hashes
      5. Summary
    15. 6. Managing data with Hiera
      1. Why Hiera?
        1. Data needs to be maintained
        2. Settings depend on nodes
        3. Operating systems differ
        4. The Hiera way
      2. Setting up Hiera
      3. Adding Hiera data to your Puppet repo
        1. Troubleshooting Hiera
      4. Querying Hiera
        1. Typed lookups
      5. Types of Hiera data
        1. Single values
        2. Boolean values
        3. Arrays
        4. Hashes
      6. Interpolation in Hiera data
        1. Using lookup()
        2. Using alias()
        3. Using literal()
      7. The hierarchy
        1. Dealing with multiple values
        2. Merge behaviors
        3. Data sources based on facts
        4. What belongs in Hiera?
      8. Creating resources with Hiera data
        1. Building resources from Hiera arrays
        2. Building resources from Hiera hashes
        3. The advantages of managing resources with Hiera data
      9. Managing secret data
        1. Setting up GnuPG
        2. Adding an encrypted Hiera source
        3. Creating an encrypted secret
        4. How Hiera decrypts secrets
        5. Editing or adding encrypted secrets
        6. Distributing the decryption key
      10. Summary
    16. 7. Mastering modules
      1. Using Puppet Forge modules
        1. What is the Puppet Forge?
        2. Finding the module you need
        3. Using r10k
        4. Understanding the Puppetfile
        5. Managing dependencies with generate-puppetfile
      2. Using modules in your manifests
        1. Using puppetlabs/mysql
        2. Using puppetlabs/apache
        3. Using puppet/archive
      3. Exploring the standard library
        1. Safely installing packages with ensure_packages
        2. Modifying files in place with file_line
        3. Introducing some other useful functions
        4. The pry debugger
      4. Writing your own modules
        1. Creating a repo for your module
        2. Writing the module code
        3. Creating and validating the module metadata
        4. Tagging your module
        5. Installing your module
        6. Applying your module
        7. More complex modules
        8. Uploading modules to Puppet Forge
      5. Summary
    17. 8. Classes, roles, and profiles
      1. Classes
        1. The class keyword
        2. Declaring parameters to classes
        3. Automatic parameter lookup from Hiera data
      2. Parameter data types
        1. Available data types
        2. Content type parameters
        3. Range parameters
        4. Flexible data types
      3. Defined resource types
        1. Type aliases
      4. Managing classes with Hiera
        1. Using include with lookup()
        2. Common and per-node classes
      5. Roles and profiles
        1. Roles
        2. Profiles
      6. Summary
    18. 9. Managing files with templates
      1. What are templates?
        1. The dynamic data problem
        2. Puppet template syntax
      2. Using templates in your manifests
        1. Referencing template files
        2. Inline templates
        3. Template tags
        4. Computations in templates
        5. Conditional statements in templates
      3. Iteration in templates
        1. Iterating over Facter data
        2. Iterating over structured facts
        3. Iterating over Hiera data
        4. Working with templates
        5. Passing parameters to templates
        6. Validating template syntax
        7. Rendering templates on the command line
        8. Legacy ERB templates
      4. Summary
    19. 10. Controlling containers
      1. Understanding containers
        1. The deployment problem
        2. Options for deployment
        3. Introducing the container
        4. What Docker does for containers
      2. Deployment with Docker
        1. Building Docker containers
        2. The layered filesystem
        3. Managing containers with Puppet
      3. Managing Docker with Puppet
        1. Installing Docker
        2. Running a Docker container
        3. Stopping a container
        4. Running multiple instances of a container
      4. Managing Docker images
        1. Building images from Dockerfiles
        2. Managing Dockerfiles
      5. Building dynamic containers
        1. Configuring containers with templates
        2. Self-configuring containers
      6. Persistent storage for containers
        1. Host-mounted volumes
        2. Docker volumes
      7. Networking and orchestration
        1. Connecting containers
        2. Container orchestration
        3. What is orchestration?
        4. What orchestration tools are available?
      8. Running Puppet inside containers
        1. Are containers mini VMs or single processes?
        2. Configuring containers with Puppet
        3. Containers need Puppet too
      9. Summary
    20. 11. Orchestrating cloud resources
      1. Introducing the cloud
        1. Automating cloud provisioning
        2. Using CloudFormation
        3. Using Terraform
        4. Using Puppet
      2. Setting up an Amazon AWS account
        1. Creating an AWS account
        2. Creating an IAM policy
        3. Creating an IAM user
        4. Storing your AWS credentials
      3. Getting ready to use puppetlabs/aws
        1. Creating a key pair
        2. Installing the puppetlabs/aws module
        3. Installing the AWS SDK gem
      4. Creating EC2 instances with Puppet
        1. Choosing an Amazon Machine Image (AMI)
        2. Creating the EC2 instance
        3. Accessing your EC2 instance
        4. VPCs, subnets, and security groups
        5. The ec2_securitygroup resource
        6. The ec2_instance resource
      5. Managing custom VPCs and subnets
        1. Creating an instance in a custom VPC
        2. The ec2_vpc resource
        3. The ec2_vpc_internet_gateway resource
        4. The ec2_vpc_routetable resource
        5. The ec2_vpc_subnet resource
        6. Other AWS resource types
      6. Provisioning AWS resources from Hiera data
        1. Iterating over Hiera data to create resources
        2. Cleaning up unused resources
      7. Summary
    21. 12. Putting it all together
      1. Getting the demo repo
        1. Copying the repo
      2. Understanding the demo repo
        1. The control repo
        2. Module management
        3. Classes
        4. Roles
        5. Profiles
        6. Users and access control
        7. SSH configuration
        8. Sudoers configuration
        9. Time zone and clock synchronization
        10. Puppet configuration
      3. The bootstrap process
      4. Adapting the repo for your own use
        1. Configuring users
        2. Adding per-node data files and role classes
        3. Modifying the bootstrap credentials
      5. Bootstrapping a new node
        1. Bootstrapping a Vagrant VM
        2. Bootstrapping physical or cloud nodes
        3. Using other distributions and providers
      6. Summary
      7. The beginning
    22. Index

Product information

  • Title: Puppet 5 Beginner's Guide - Third Edition
  • Author(s): John Arundel
  • Release date: October 2017
  • Publisher(s): Packt Publishing
  • ISBN: 9781788472906