Book Image

Learning Puppet Security

Book Image

Learning Puppet Security

Overview of this book

Table of Contents (17 chapters)
Learning Puppet Security
About the Author
About the Reviewers


Using Puppet is currently one of the hottest trends right now in the IT industry. As the industry moves away from manual provisioning towards automation, the usage of Puppet and its associated tools will only continue to grow.

With the rise of automation, and the repetitive tasks that security often entails, it makes perfect sense for Puppet to be a strong security tool. With proper configuration, Puppet can assist in securing your servers, showing compliance with various standards, and generally easing the workload of security-related personnel.

This book is a practical introduction to Puppet for security professionals. It will guide you into the world of automation, showing you how to make repetitive tasks a breeze. With the knowledge learned here, you can begin the process of bringing your system configurations into code, where they can be audited and treated much like you would treat a code base.

Starting with the beginning, and assuming that you only have the knowledge of Linux operating systems, we will explore the basics of Puppet. From there on, we will cover examples and concepts of increasing complexity and skill until you are ready to start on your own. In doing this, we will cover using the Puppet code for auditing, as well as using reports and other data to show compliance. We'll explore centralized logging, and learn how you can use Puppet to make your SELinux tasks easier.

What this book covers

Chapter 1, Puppet as a Security Tool, provides an introduction to Puppet. We'll build a development environment that we'll use in all the chapters, and explore some simple examples with Puppet.

Chapter 2, Tracking Changes to Objects, explores various ways to audit changes to resources, such as files. Puppet provides a number of ways to handle this, and we'll review their pros and cons.

Chapter 3, Puppet for Compliance, looks at the use of Puppet for compliance purposes. Version control for our manifests will be introduced, and it will explain how the manifests can be used for auditing and compliance purposes. We'll also review some specific examples of how Puppet can help with the PCI DSS.

Chapter 4, Security Reporting with Puppet, looks at how to report on some of the things we covered in the previous chapters. We'll build reporting on various system facts, as well as some simple reporting covering when Puppet last ran on our hosts.

Chapter 5, Securing Puppet, covers what it takes to secure Puppet itself. Since Puppet is in charge of all of your systems, ensuring that it is secure is important. We'll cover the various security configuration files Puppet uses, as well as how it uses SSL to ensure security.

Chapter 6, Community Modules for Security, takes a look at various modules that are available at the Puppet Forge. We'll explore modules to make managing various configuration files easier, as well as modules that provide some security hardening of hosts.

Chapter 7, Network Security and Puppet, will explore using Puppet to manage the firewall of the local host. We'll primarily be concentrating on the Puppet module, which manages iptables and its associated set of tools that are used to manage firewall rules. We'll also cover how to extend your modules to handle firewall resources.

Chapter 8, Centralized Logging, introduces the use of Puppet to manage centralized logging using Logstash. We'll cover the installation of Logstash as well as its dashboard component, Kibana. We'll then build a simple module to ship logs to a central server.

Chapter 9, Puppet and OS Security Tools, covers using Puppet to manage SELinux and auditd. We'll cover the options available for Puppet for SELinux, as well as community modules for both SELinux and auditd.

Appendix, Going Further, covers information on developing good modules, an analysis of Puppet device management, useful reporting tools, and a brief discussion on the Puppet community.

What you need for this book

The examples in this book are all written using CentOS 6. The source present in this book uses Vagrant to run the examples. Vagrant is a wonderful tool to use for development, as it allows you to specify how full virtual machines should be configured.

To use Vagrant, you'll need the following software:

Who this book is for

This book is targeted at experienced system administrators who focus on security, and it also targets security professionals. It assumes an intermediate to advanced level of system administration ability, but does not require any previous experience with Puppet.


In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "If not specified, this defaults to $vardir/reports, so /var/lib/puppet/reports on CentOS."

A block of code is set as follows:

node default {
        include openssh
        include users
        include clamav
        include puppetdb
        include puppetdb::master::config

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

node default {
        include openssh
        include users
        include clamav
        include puppetdb
        include puppetdb::master::config

Any command-line input or output is written as follows:

# sudo service puppetmaster restart


Warnings or important notes appear in a box like this.


Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title via the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at If you purchased this book elsewhere, you can visit and register to have the files e-mailed directly to you.


Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from


Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.


You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.