Book Image

Puppet 5 Cookbook - Fourth Edition

By : Thomas Uphill
Book Image

Puppet 5 Cookbook - Fourth Edition

By: Thomas Uphill

Overview of this book

Puppet is a configuration management system that automates all your IT configurations, giving you control of managing each node. Puppet 5 Cookbook will take you through Puppet's latest and most advanced features, including Docker containers, Hiera, and AWS Cloud Orchestration. Updated with the latest advancements and best practices, this book delves into various aspects of writing good Puppet code, which includes using Puppet community style, checking your manifests with puppet-lint, and learning community best practices with an emphasis on real-world implementation. You will learn to set up, install, and create your first manifests with version control, and also learn about various sysadmin tasks, including managing configuration files, using Augeas, and generating files from snippets and templates. As the book progresses, you'll explore virtual resources and use Puppet's resource scheduling and auditing features. In the concluding chapters, you'll walk through managing applications and writing your own resource types, providers, and external node classifiers. By the end of this book, you will have learned to report, log, and debug your system.
Table of Contents (16 chapters)
Title Page
Packt Upsell
Contributors
Preface
Index

Setting up the environment


Environments in Puppet are directories holding different versions of your Puppet manifests. Whenever a node connects to a Puppet master, it informs the Puppet master of its environment. By default, all nodes report to the production environment. This causes the Puppet master to look in the production environment for manifests. You may specify an alternate environment with the--environmentsetting when running puppet agent or by settingenvironment = newenvironmentin/etc/puppet/puppet.conf in the agent section.

Getting ready

Verify environmentpath in your installation with the following puppet config command:

[vagrant@puppet ~]$ sudo /opt/puppetlabs/bin/puppet config print environmentpath
/etc/puppetlabs/code/environments

How to do it...

The steps are as follows:

  1. Create a production directory at /etc/puppetlabs/code/environments that contains both a modules and manifests directory. Then, create a site.pp that creates a file in /tmp, as follows:
[vagrant@puppet ~]$ sudo mkdir...