Mastering Puppet 5

Book description

Leverage Puppet 5 for medium to large scale enterprise deployment.

Key Features

  • Use and deploy Puppet 5, irrespective the size of your organization
  • Scaling, performance improvements, and managing multiple developer requests
  • Troubleshooting techniques, tips and tricks to make the most of Puppet 5

Book Description

Puppet is a configuration management system and a language written for and by system administrators to manage a large number of systems efficiently and prevent configuration drift.

The core topics this book addresses are Puppet's latest features and mastering Puppet Enterprise. You will begin by writing a new Puppet module, gaining an understanding of the guidelines and style of the Puppet community. Following on from this, you will take advantage of the roles and profiles pattern, and you will learn how to structure your code. Next, you will learn how to extend Puppet and write custom facts, functions, types, and providers in Ruby, and also use the new features of Hiera 5. You will also learn how to configure the new Code Manager component, and how to ensure code is automatically deployed to (multiple) Puppet servers. Next, you will learn how to integrate Puppet with Jenkins and Git to build an effective workflow for multiple teams, and use the new Puppet Tasks feature and the latest Puppet Orchestrator language extensions. Finally, you will learn how to scale and troubleshoot Puppet.

By the end of the book, you will be able to deal with problems of scale and exceptions in your code, automate workflows, and support multiple developers working simultaneously.

What you will learn

  • Solve problems using modules and the roles and profiles pattern
  • Extend Puppet with custom facts, functions, types, and providers
  • Use Hiera 5 and Code Manager/r10k to separate code from data
  • Continuously integrate your code using Jenkins, Git and automated testing
  • Use exported resources and the new Puppet Orchestration features
  • Explore Puppet Discovery features and their use
  • Troubleshoot various parts of the Puppet Enterprise infrastructure
  • Scale up and scale out Puppet infrastructure using various techniques

Who this book is for

If you are a system administrator or developer who has used Puppet in production and are looking for ways to easily use Puppet in an enterprise environment, this book is for you. Some knowledge of writing simple configuration management modules would be necessary.

Table of contents

  1. Title Page
  2. Copyright and Credits
    1. Mastering Puppet 5
  3. Dedication
  4. Packt Upsell
    1. Why subscribe?
    2. packt.com
  5. Contributors
    1. About the authors
    2. About the reviewer
    3. Packt is searching for authors like you
  6. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
      1. Download the example code files
      2. Download the color images
      3. Conventions used
    4. Get in touch
      1. Reviews
  7. Authoring Modules
    1. Using a decent IDE and plugins
      1. Vim
      2. TextMate
      3. Atom
      4. Visual Studio
    2. Using good module and class structure
      1. Following the class-naming conventions
      2. Having a single point of entry to the module
      3. Using high cohesion and loose coupling principles
      4. Using the encapsulation principle
      5. Providing sensible, well-thought-out parameter defaults
      6. Strongly typing your module variables
    3. Using the new Puppet Development Kit commands
    4. Validating your module
    5. Unit testing your module
    6. Staying on the lookout for code smells
    7. Working with dead code
    8. Using Puppet Forge
    9. Working with the community
    10. Writing great documentation
      1. Grabbing yourself a Markdown editor
        1. Vim
        2. TextMate
        3. Atom
        4. Visual Studio
        5. Standalone Markdown editors
        6. Remarkable
        7. MacDown
    11. Adding module dependencies
    12. Adding compatibility data for your modules
      1. Operating systems support
      2. Puppet and PE version support
    13. Using the new Hiera 5 module level data
    14. Summary
  8. Roles and Profiles
    1. Summary of the pattern
    2. Profiles
      1. Profiles best practices summary
        1. Designing for use of the include keyword
        2. Using subdirectories for sensible, readable profile class groups
        3. Hiding complexity with parameters, defaults, and abstraction
        4. Deciding how to set the parameters for component classes
        5. Deciding to use either automatic class parameter lookup or the lookup function
    3. Roles
      1. Roles best practices summary
        1. Constructing roles only with the include keyword
        2. Naming roles in your business's conversational name
        3. Deciding on the granularity of roles for your nodes
    4. Summary
  9. Extending Puppet
    1. Custom facts
      1. Debugging facts
    2. Custom functions
    3. Types and providers
      1. Types
        1. Creating and distributing the type
        2. Adding the namevar special attribute
        3. Adding additional type properties
        4. Adding the optional ensure property
        5. Adding type parameters
        6. Setting property and parameter defaults
        7. Checking the input value with a validate block
        8. Checking the input value against a newvalues array
        9. Checking datatype compatibility with munge
        10. Using autorequire for implicit relationships
        11. Using arrays to assign a list of values to an attribute
        12. Using the desc method to add inline documentation
      2. Providers
        1. Creating and distributing the provider
        2. Indicating the suitability of the provider to the type
          1. Using the confine method
          2. Using the defaultfor method
          3. Using the commands method
        3. Implementing the ensure property
          1. Using the exists? method
          2. Using the create and destroy methods
        4. Using the GET and SET methods to manage type properties
        5. Implementing the self.instances method
    4. Summary
  10. Hiera 5
    1. Separation of concerns between code and data
    2. Introducing a frame for the environment
    3. A more complete hierarchy
    4. Hiera 5 summary
    5. Global, environment, and module layers
    6. Encrypted YAML backend
      1. Installing hiera-eyaml
      2. Creating the encryption keys
      3. Securely storing away the encryption keys
      4. Changing hiera.yaml
    7. Lookup function
      1. The lookup function syntax
      2. Lookup function arguments
      3. Lookup function examples
      4. Lookup strategies
      5. Deep merge lookup settings explained
        1. knockout_prefix setting
        2. sort_merge_arrays setting
        3. merge_hash_arrays setting
        4. unpack_arrays setting
    8. Debugging Hiera
      1. Old debugging techniques
      2. Equivalent debugging technique
    9. Beyond Hiera using Jerakia
      1. Jerakia advanced use cases
        1. Installing Jerakia
        2. Configuring Jerakia
        3. Creating your default Jerakia policy
        4. Using Vault as an encryption backend
        5. Installing and configuring Vault
        6. Unsealing Vault
        7. Enabling the transit backend
        8. Creating an encryption key
        9. Creating a policy for encrypting and decrypting
        10. Checking the encryption is working correctly
        11. Allowing Jerakia to authenticate with our Vault
        12. Configuring Jerakia for encryption
        13. Encryption-enabling our Jerakia lookups
    10. Summary
  11. Managing Code
    1. Efficiently managing code
    2. Code Manager
      1. Git
      2. r10k
        1. Control repository
          1. production-like environments
          2. non-production-like environments
          3. Puppetfile
          4. hiera.yaml
          5. site.pp
          6. environment.conf
          7. Roles and profiles
          8. Control repository example
        2. Installing and using r10k
      3. Code Manager
        1. Enabling Code Manager
          1. Code Manager RBAC
        2. PE client tools
    3. Multitenant control repository
    4. Summary
  12. Workflow
    1. Puppet workflow
      1. Ease of use
      2. Rapid feedback
      3. Ease of onboarding
      4. Quality control
    2. Designing a Puppet workflow
      1. Components of the Puppet workflow
        1. Repositories
          1. Control repository
          2. Module repository
        2. Tasks
          1. Clone and edit the component repositories
          2. Cloning the control repository
          3. Editing the control repository
          4. Deploying the new environment on the Puppet Master
          5. Testing the changes
          6. Merging branches
          7. Git tags and versioning
    3. Using the PDK
      1. PDK
        1. Creating new Puppet artifacts
          1. The pdk new command
        2. The pdk validate command
        3. The pdk test unit command
    4. Summary
  13. Continuous Integration
    1. Continuous Integration systems
      1. Puppet Pipelines
      2. Jenkins
        1. Managing Jenkins with Puppet
          1. rtyler/jenkins
      3. Managing our plugins
      4. Creating our first build
        1. Building our profile module
        2. Building our Jenkinsfile
        3. Connecting Jenkins to our repository
      5. Integrating the PDK
    2. Unit testing with Puppet RSpec
      1. Relevant RSpec files
        1. .fixtures.yml
        2. jenkins_spec.rb
        3. Extending our Jenkinsfile
      2. Extending our test
    3. Acceptance testing with Test Kitchen
      1. Beaker
      2. Test Kitchen and kitchen-puppet
        1. Preparing Test Kitchen on our Jenkins node
          1. Jenkins Profile
          2. .kitchen.yml
          3. Puppetfile
          4. Jenkinsfile
          5. acceptance.sh
          6. Test
          7. Performing the test
    4. Summary
  14. Extending Puppet with Tasks and Discovery
    1. Puppet Tasks
      1. Bolt
        1. Installing Bolt
        2. Managing nodes
        3. Ad hoc commands
        4. Bolt tasks
          1. task.json
          2. Task
        5. Bolt plans
      2. Puppet Enterprise Task Management
    2. Puppet Discovery
      1. Installing Discovery
        1. Preparing Puppet Discovery
      2. Managing sources
        1. Adding sources by IP address
      3. Managing credentials
        1. SSH key file
      4. Discovering
        1. Viewing the Discovery
        2. Discovering hosts
        3. Discovering packages
      5. Acting
        1. Installing agents
        2. Managing services
      6. Uses for Discovery
    3. Summary
  15. Exported Resources
    1. Virtual and exported resources
      1. Virtual resources
      2. Tags
      3. Exported resources
    2. Use cases
      1. Hosts file
      2. Load balancing
      3. Database connections
      4. Concat, file lines, and you!
        1. Concat – the hammer
        2. file_line – the scalpel
    3. Summary
  16. Application Orchestration
    1. Application definition
    2. Application components
    3. Service resources
    4. Modeling applications
      1. Application and database
        1. Dependencies
        2. Build
          1. Node declaration
          2. Application declaration
          3. DB service resource
          4. Application components
        3. Deploy
      2. Adding a load balancer and providing horizontal scaling
        1. Dependencies
        2. Build
        3. Deploy
    5. Summary
  17. Scaling Puppet
    1. Inspection
      1. Puppetserver
      2. PuppetDB dashboard
    2. Tuning
      1. Puppetserver tuning
        1. Puppet Enterprise implementation
        2. Open source implementation
      2. PuppetDB tuning
        1. Deactivating and purging nodes
        2. Managing the heap size
        3. Tuning CPU threads
      3. Automatically determining settings
        1. Puppet Enterprise
        2. PuppetDB – PostgreSQL with PGTune
    3. Horizontal scaling
      1. Puppetserver
        1. Estimating the number of agents a Puppetserver supports
        2. Adding new compile masters
        3. Load balancing
          1. Simple setup – direct connection
          2. Load balancing
        4. Certificate authority
      2. PuppetDB
    4. Summary
  18. Troubleshooting and Profiling
    1. Common component errors
      1. Puppet agents and Puppetserver
        1. Waiting on certificate signing
        2. Certificate reuse
        3. Wrong Puppet user
        4. Network connectivity
        5. DNS alt name
        6. Date and time
        7. PE console service is down
    2. Catalog errors
      1. Syntax errors
      2. Duplicate resource declaration
      3. Missing resources
        1. Autoload format
      4. Circular dependencies
      5. Debug mode – catalog
    3. Logging
      1. The logback.xml file
        1. Main configuration
        2. Appender
        3. Loggers
        4. Root logger
      2. Puppet agent
      3. PuppetDB
      4. Puppetserver
      5. Puppet Enterprise console
    4. Summary
  19. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think

Product information

  • Title: Mastering Puppet 5
  • Author(s): Ryan Russell-Yates, Jason Southgate
  • Release date: September 2018
  • Publisher(s): Packt Publishing
  • ISBN: 9781788831864