Book Image

Extending Puppet - Second Edition

By : Alessandro Franceschi, Jaime Soriano Pastor
Book Image

Extending Puppet - Second Edition

By: Alessandro Franceschi, Jaime Soriano Pastor

Overview of this book

Puppet has changed the way we manage our systems, but Puppet itself is changing and evolving, and so are the ways we are using it. To tackle our IT infrastructure challenges and avoid common errors when designing our architectures, an up-to-date, practical, and focused view of the current and future Puppet evolution is what we need. With Puppet, you define the state of your IT infrastructure, and it automatically enforces the desired state. This book will be your guide to designing and deploying your Puppet architecture. It will help you utilize Puppet to manage your IT infrastructure. Get to grips with Hiera and learn how to install and configure it, before learning best practices for writing reusable and maintainable code. You will also be able to explore the latest features of Puppet 4, before executing, testing, and deploying Puppet across your systems. As you progress, Extending Puppet takes you through higher abstraction modules, along with tips for effective code workflow management. Finally, you will learn how to develop plugins for Puppet - as well as some useful techniques that can help you to avoid common errors and overcome everyday challenges.
Table of Contents (19 chapters)
Extending Puppet Second Edition
Credits
About the Authors
About the Reviewer
www.PacktPub.com
Preface
Index

Preface

Puppet has changed the way we manage our systems.

When it was released, other configuration management tools were around, but it was clear that it had something special. It came at the right time with the right approach. The challenges of IT infrastructures were beginning to step up to a new level, and the need to automate common activities such as a quick setup and configuration of systems was becoming a requirement. Puppet presented a sane model, based on the abstraction of resources and the definition of the expected state of a system, using a clear and sysadmin-friendly language.

There are various books about Puppet around, and most of them are very good. This one tries to contribute with solid, no frills content (few pictures, few large blocks of copied and pasted text) and some new perspectives and topics. It begins with an intense technical overview of Puppet, Hiera, and PuppetDB, so that you can use them to design appropriate Puppet architectures that fit your IT infrastructure.

We will explore where our data can be placed, how to design reusable modules, and how they can be used as building blocks for higher abstraction classes. We will try to give a clearer and wider view of what it means to work with Puppet and what are the challenges to face when we introduce it in our systems, from code management to deployment rollouts. We will dive into Puppet's internals and its extension points, showing the multiple ways we can tweak, extend, and hack with it. We will also look at less traditional fields, such as Puppet as a configuration management tool for network devices or cloud services.

Since the first edition of this book was published by Alessandro in 2014, it has been a reference for both learners that wanted to start with Puppet and for experienced users that were looking for a deeper understanding of this tool. During these years, some things have changed in Puppet and the content of the book needed to be refreshed. Probably the most important release of Puppet till now, version 4, happened and it introduced some changes in several aspects. This edition covers the main differences that appeared with this new version, how it is installed, compatibility between versions, and so on. It also adds descriptions for the new language features so it can continue being used as a reference for learners of all levels. Some of the contents that may have become obsolete have been updated or replaced by new implementations or better practices. Some sections have been extended to provide further details on things that have proven to be of interest to the community. And in the last chapter, we will also analyze some of the steps Puppet is taking or will take in the future.

What this book covers

Chapter 1, Puppet Essentials, is an intense and condensed summary of the most important Puppet concepts; it acts as the baseline needed to understand the chapters that follow and a good occasion to refresh and maybe enrich knowledge about the Puppet language and model.

Chapter 2, Managing Puppet Data with Hiera, is dedicated to how to manage our data with Hiera, define the lookup hierarchy, organize data, and use different backends.

Chapter 3, Introducing PuppetDB, covers the installation, configuration, and usage of PuppetDB, and explores the great possibilities that it may enable in the next generations of modules.

Chapter 4, Designing Puppet Architectures, outlines the components to manage when defining a Puppet architecture: the available tools, how to integrate them, how to cope with data and code, and how to organize resources to be applied to nodes.

Chapter 5, Using and Writing Reusable Modules, covers the most important Puppet element from the user's perspective: modules and how to write them in order to be able to reuse them in different infrastructures.

Chapter 6, Higher Abstraction Modules, takes a step further and focuses on modules that use different application modules to compose more complex and wider scenarios.

Chapter 7, Puppet Migration Patterns, analyzes the approaches that can be taken when introducing Puppet in a new or existing infrastructure: methodologies, patterns, techniques, and tips for a successful deployment.

Chapter 8, Code Workflow Management, focuses on how to manage Puppet code, from when is written in an editor, to its management with an SCM, its testing and deployment, and into production.

Chapter 9, Scaling Puppet Infrastructures, faces the challenges in growing infrastructures and how it is possible to make Puppet scale with them.

Chapter 10, Extending Puppet, covers the many available possibilities to extend the core code with custom plugins and gives a deeper view of how Puppet's internals are organized.

Chapter 11, Beyond the System, takes a journey outside the traditional territories, exploring how we can manage with the Puppet network, as well as storage equipment and cloud instances.

Chapter 12, Future Puppet, is a step beyond Puppet 4 and how the project may evolve in future versions.

What you need for this book

You can test the Puppet code present in this book on any Linux system connected to the Internet.

Who this book is for

This book is accessible to any Puppet user.

If you are totally new to Puppet, be sure to thoroughly read Chapter 1, Puppet Essentials, and have properly understood its principles before continuing.

If you are an intermediate user, it is recommended that you read the chapters in order.

If you are an advanced user, you may pick from different pages useful information and new insights on topics you should already know.

Conventions

In this book, you will find a number of text styles 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: "When the Master receives a connection then it looks in its manifests (starting from /etc/puppet/manifests/site.pp) what resources have to be applied for that client host, also called node."

A block of code is set as follows:

class my_users {
  @user { 'al': […] tag => 'admins' }
  @user { 'matt': […] tag => 'developers' }
  @user { 'joe': [… tag => 'admins' }
[ … ]
}

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

ls -l $(facter rubysitedir)/puppet/provider/package/

Note

Warnings or important notes appear in a box like this.

Tip

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 disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail , and mention the book's title in 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 at www.packtpub.com/authors.

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.

Errata

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 could 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 http://www.packtpub.com/submit-errata, 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 to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyrighted 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.

Questions

If you have a problem with any aspect of this book, you can contact us at , and we will do our best to address the problem.