Extending Puppet - Second Edition - Alessandro Franceschi - E-Book

Extending Puppet - Second Edition E-Book

Alessandro Franceschi

0,0
33,59 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.

Mehr erfahren.
Beschreibung

Start pulling the strings of your infrastructure with Puppet – learn how to configure, customize, and manage your systems more intelligently

About This Book

  • Explore the wider Puppet ecosystem of useful tools
  • Design and manage your Puppet architecture for optimum performance
  • Write more efficient code that keeps your infrastructure more robust

Who This Book Is For

If you are a Puppet user, this book will help you on different levels. If you a beginner, we summarize the key Puppet components and give you the elements to have a broader vision. For more experienced users, you will be surprised by with topics on designing, implementing, adapting, and deploying Puppet architectures. If you are expert, you will find topics and information that is rarely exposed in other books, giving you an insight into Puppet's future and its usage on alternative devices.

What You Will Learn

  • Learn the principles of Puppet language and ecosystem
  • Extract the features of Hiera and PuppetDB's power usage
  • Explore the different approaches to Puppet architecture design
  • Use Puppet to manage network, cloud, and virtualization devices
  • Manage and test the Puppet code workflow
  • Tweak, hack, and adapt the Puppet extension points
  • Get a run through of the strategies and patterns to introduce Puppet automation
  • Master the art of writing reusable modules

In Detail

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.

Style and approach

This is a collection of specific information about multiple topics related to Puppet and its ecosystem. Starting from a review of the very basics to more advanced topics, mixing practical advice with important theory and broader perspective, along with implementation details.

Sie lesen das E-Book in den Legimi-Apps auf:

Android
iOS
von Legimi
zertifizierten E-Readern

Seitenzahl: 432

Veröffentlichungsjahr: 2016

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Table of Contents

Extending Puppet Second Edition
Credits
About the Authors
About the Reviewer
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Errata
Piracy
Questions
1. Puppet Essentials
The Puppet ecosystem
Why configuration management matters
Puppet components
Installing and configuring Puppet
Puppet in action
Resources
The resource abstraction layer
Nodes
Classes and defines
Class inheritance
Resource defaults
Resource references
Variables, facts, and scopes
System's facts
External facts
User variables in Puppet DSL
Type-checking
User variables in an ENC
User variables in Hiera
Puppet built-in variables
Variables scope
Meta parameters
Managing order and dependencies
Run stages
Reserved names and allowed characters
Conditionals
Comparison operators
Iteration and lambdas
The in operator
Expressions combinations
Exported resources
Virtual resources
Modules
Paths of a module and auto loading
Templates
Restoring files from a filebucket
Summary
2. Managing Puppet Data with Hiera
Installing and configuring Hiera
The hiera.yaml configuration file
Global settings
Backend specific settings
Examples
Working with the command line on a YAML backend
Using Hiera in Puppet
Dealing with hashes in Puppet code
Puppet 3 automatic parameter lookup
Evolving usage patterns for class parameters
Additional Hiera backends
Hiera-file
Encryption plugins
Hiera-gpg
Hiera-eyaml
Hiera-http, hiera-mysql
Using Hiera as an ENC
Summary
3. Introducing PuppetDB
Installation and configuration
Installing PuppetDB
PuppetDB configurations
Init script configuration
Configuration settings
Logging configuration
Configurations on the Puppet Master
Dashboards
PuppetDB performance dashboard
Puppetboard—Querying PuppetDB from the Web
PuppetDB API
Querying PuppetDB (read)
PuppetDB commands (write)
Querying PuppetDB for fun and profit
/facts endpoint
/resources endpoint
/nodes endpoint
/catalogs endpoint
/fact-names endpoint
/metrics endpoint
/reports endpoint
/events endpoint
/event-counts endpoint
/aggregated-event-counts endpoint
/server-time endpoint
/version endpoint
The puppetdbquery module
Query format
Querying from the command line
Querying from Puppet manifests
The PuppetDB Hiera backend
How Puppet code may change in the future
Summary
4. Designing Puppet Architectures
Components of a Puppet architecture
Definition of the classes to include in each node
Definition of the parameters to use for each node
Definition of the configuration files provided to the nodes
Definition of custom resources and classes
The Foreman
Roles and profiles
The data and the code
Sample architectures
The default approach
Basic ENC, logic on site module, Hiera backend
The Foreman and Hiera
Hiera-based setup
Foreman smart variables
Facts-driven truths
Nodeless site.pp
Summary
5. Using and Writing Reusable Modules
Modules layout evolution
Class parameters—from zero to data bindings
Params pattern
Data in modules
Files and class names
The anchor pattern
The parameters dilemma
Naming standards
Reusability patterns
Managing files
Managing configuration hash patterns
Managing multiple configuration files
Managing users and dependencies
Managing installation options
Managing extra resources
Summary
6. Higher Abstraction Modules
The OpenStack example
Component (application) modules
Raising abstraction – the official OpenStack module
Raising abstraction – Puppet Labs OpenStack module
Taking an alternate approach
An approach to reusable stack modules
Tiny Puppet
Summary
7. Puppet Migration Patterns
Examining potential scenarios and approaches
New infrastructures
Existing manually managed infrastructures
Node migration
Node update
Existing automated infrastructures
Patterns for extending Puppet coverage
Raising the bar, step by step
Knowing the territory
Defining priorities
Evaluating solutions
Coding
Applying changes
Things change
Puppet friendly infrastructure
Puppet-friendly software
Summary
8. Code Workflow Management
Write Puppet code
Geppetto
Vim
Git workflows
Code management using Git
Git hooks
Environments and branches
Branch based automatic environments
Simplified developer workdir environments
Code review
Gerrit
Online resources for peer review
Testing Puppet code
Using rspec-puppet
Vagrant
Beaker and beaker-rspec
Deploying Puppet code
Using librarian-puppet for deployments
Deploying code with r10k
Propagating Puppet changes
Puppet continuous integration
Travis
Jenkins
Summary
9. Scaling Puppet Infrastructures
Scaling Puppet
As simple as puppet apply
Default Puppet Master
Puppet Master with Passenger
Installing and configuring Passenger
Puppet Master based on Trapperkeeper
Multi-Master scaling
Managing certificates
Managing SSL termination
Managing code and data
Load balancing alternatives
Masterless Puppet
Configurations and infrastructure optimizations
Traffic compression
Caching
Distributing Puppet run times
File system changes check
Scaling stored configs
Measuring performance
Puppet Metrics
Optimizing code
Testing different Puppet versions
Summary
10. Extending Puppet
Anatomy of a Puppet run, under the hood
Puppet extension alternatives
ENC and Hiera Extendibility
Modules pluginsync
Puppet indirector and its termini
Custom functions
Custom facts
Ruby facts distributed via pluginsync
External facts in facts.d directory
Custom types and providers
Custom report handlers
Custom faces
Summary
11. Beyond the System
Puppet on network equipment
Proxy mode with Puppet device application
Native Puppet on network equipment
Cisco onePK
Juniper and the netdev_stdlib
Puppet for cloud and virtualization
VMware
VM provisioning on vCenter and vSphere
vCenter configuration
vSphere virtual machine management with resource types
Amazon Web Services
Cloud provisioning on AWS
AWS provisioning and configuration with resource types
Managing CloudFormation
Cloud provisioning on Google Compute Engine
Puppet on storage devices
Puppet and Docker
Summary
12. Future Puppet
Changing the serialization format
Direct Puppet
File sync
Other changes
Certificate authority in Clojure
Package management
Changes in faces
Beyond Puppet 4.x
Summary
Index

Extending Puppet Second Edition

Extending Puppet Second Edition

Copyright © 2016 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

First published: June 2016

Production reference: 1170616

Published by Packt Publishing Ltd.

Livery Place

35 Livery Street

Birmingham B3 2PB, UK.

ISBN 978-1-78588-568-6

www.packtpub.com

Credits

Authors

Alessandro Franceschi

Jaime Soriano Pastor

Reviewer

Jeroen Hooyberghs

Commissioning Editor

Priya Singh

Acquisition Editors

Chaitanya Nair

Shaon Basu

Content Development Editor

Merint Thomas Mathew

Technical Editor

Deepti Tuscano

Copy Editor

Merilyn Pereira

Project Coordinator

Francina Pinto

Proofreader

Safis Editing

Indexer

Mariammal Chettiyar

Production Coordinator

Arvindkumar Gupta

Cover Work

Arvindkumar Gupta

About the Authors

Alessandro Franceschi is a long time Puppet user, trainer, and consultant.

He started using Puppet in 2007, automating a remarkable amount of customers' infrastructures of different sizes, natures, and complexities.

He has attended several PuppetConf and PuppetCamps as both speaker and participant, always enjoying the vibrant and friendly community, each time learning something new.

Over the years, he started to publish his Puppet code, trying to make it reusable in different scenarios. The result of this work is the example42 Puppet modules and control repo, complete, feature rich, sample Puppet environment. You can read about example42 at www.example42.com.

You can follow Franceschi on his Twitter account at @alvagante.

Jaime Soriano Pastor was born in Teruel, a small city in Spain. He has always been a passionate about technology and sciences. While studying computer science at the university in his hometown, he had his first encounter with Linux and free software, which is what shaped his career.

He worked for several companies on different and interesting projects, from operating systems in embedded devices to the cloud, giving him a wide view on several fields of software development and systems administration.

Currently, automation, configuration management, and continuous integration form a part of his daily work in the SRE team at Tuenti Technologies.

About the Reviewer

Jeroen Hooyberghs is an open source and Linux enthusiast, available as consultant at Open-Future in Belgium. In this position, as well as in previous jobs in Linux system administration, he built his technical expertise in a lot of open source solutions. In the last couple of years he's been focusing on system automization and configuration management, mainly using Puppet. Since 2014, he's been a Puppet Certified Professional and Puppet trainer.

As a technical reviewer, he contributed to other Packt Publishing books, such as Mastering Puppet by Thomas Uphill and Puppet Cookbook by John Arundel and Thomas Uphill.

www.PacktPub.com

Support files, eBooks, discount offers, and more

For support files and downloads related to your book, please visit www.PacktPub.com.

Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at <[email protected]> for more details.

At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.

https://www2.packtpub.com/books/subscription/packtlib

Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can search, access, and read Packt's entire library of books.

Why subscribe?

Fully searchable across every book published by PacktCopy and paste, print, and bookmark contentOn demand and accessible via a web browser

Free access for Packt account holders

If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view 9 entirely free books. Simply use your login credentials for immediate access.

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 <[email protected]>, 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 <[email protected]> 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 <[email protected]>, and we will do our best to address the problem.

Chapter 1. Puppet Essentials

There are moments in our professional life when we meet technologies that trigger an inner wow effect. We realize there's something special in them and we start to wonder how they can be useful for our current needs and, eventually, wider projects. Puppet, for me, has been one of these turning point technologies. I have reason to think that we might share a similar feeling.

If you are new to Puppet, you are probably starting from the wrong place, there are better fitting titles around to grasp its basic concepts.

This book won't indulge too much on the fundamentals, but don't despair, this chapter might help for a quick start. It provides the basic Puppet background needed to understand the rest of the contents and may also offer valuable information to more experienced users.

We are going to review the following topics:

The Puppet ecosystem, its components, history, and the basic concepts behind configuration managementHow to install and configure Puppet commands and paths, to understand where things are placedThe core components and concepts; terms such as manifests, resources, nodes, and classes will become familiarThe main language elements—variables, references, resources defaults, ordering, conditionals, comparison operators, virtual and exported resourcesHow Puppet stores the changes it makes and how to revert them

The contents of this chapter are quite dense, so take your time to review and assimilate them if they sound new or look too complex; the path towards Puppet awareness is never too easy.

The Puppet ecosystem

Puppet is a configuration management and automation tool; we use it to install, configure, and manage components of our servers.

Initially written in Ruby, some parts were rewritten in version 4 in Clojure. Released with an open source license (Apache 2), it can run on any Linux distribution, many other UNIX variants (Solaris, *BSD, AIX, and Mac OS X), and Windows. Its development started in 2005 by Luke Kanies as an alternative approach to the existing configuration management tools (most notably CFEngine and BladeLogic). The project has grown year after year; Kanies' own company, Reductive Labs, renamed in 2010 to Puppet Labs, has received a total funding of $ 45.5 million in various funding rounds (among the investors there are names such as VMware, Google, and Cisco).

Now, it is one of the top 100 fastest growing companies in the US. It employs more than 150 people and it has a solid business based on open source software, consisting of consulting services, training, certifications, and Puppet Enterprise. Puppet Enterprise is the commercial version that is based on the same open source Puppet codebase, but it provides an integrated stack with lots of tools, such as a web GUI that improves and makes Puppet usage and administration easier, and more complete support for some major Linux distributions, Mac OS X, and Microsoft Windows Server.

The Puppet ecosystem features a vibrant, large, and active community, which discusses on the Puppet Users and Puppet Developers Google groups, on the crowded free node #puppet IRC channel, at the various Puppet Camps that are held multiple times a year all over the world, and at the annual PuppetConf, which is improving and getting bigger year after year.

Various software products are complementary to Puppet; some of them are developed by Puppet Labs:

Hiera: This is a key-value lookup tool that is the current choice of reference for storing data related to our Puppet infrastructure.Mcollective: This is an orchestration framework that allows parallel execution of tasks on multiple servers. It is a separate project by Puppet Labs, which works well with Puppet.Facter: This is a required complementary tool; it is executed on each managed node and gathers local information in key/value pairs (facts), which are used by Puppet.Geppetto: This is an IDE, based on Eclipse that allows easier and assisted development of Puppet code.Puppet Dashboard: This is an open source web console for Puppet.PuppetDB: This is a powerful backend that can store all the data gathered and generated by Puppet.Puppet Enterprise: This is the commercial solution to manage via a web frontend Puppet, Mcollective, and PuppetDB.

The community has produced other tools and resources. The most noticeable ones are:

The Foreman: This is a systems lifecycle management tool that integrates perfectly with Puppet.PuppetBoard: This is a web front end for PuppetDB.Kermit: This is a web front end for Puppet and Mcollective.Modules: These are reusable components that allow management of any kind of application and software via Puppet.

Why configuration management matters

IT operations have changed drastically in the past few years. Virtualization, cloud, business needs, and emerging technologies have accelerated the pace of how systems are provisioned, configured, and managed.

The manual setup of a growing number of operating systems is no longer a sustainable option. At the same time, in-house custom solutions to automate the installation and the management of systems cannot scale in terms of required maintenance and development efforts.

For these reasons, configuration management tools such as Puppet, Chef, CFEngine, Rudder, Salt, and Ansible (to mention only the most known open source ones) are becoming increasingly popular in many infrastructures.

They show infrastructure as code, that allows, in systems management, the use of some of the same best practices in software development for decades, such as maintainability, code reusability, testability, or version control.

Once we can express the status of our infrastructure with versioned code, there are powerful benefits:

We can reproduce our setups in a consistent way, what is executed once can be executed any time, the procedure to configure a server from scratch can be repeated without the risk of missing partsOur code commits log reflects the history of changes on the infrastructure; who did what, when, and if commits comments are pertinent, why.We can scale quickly; the configurations we made for a server can be applied to all the servers of the same kind.We have aligned and coherent environments; our Development, Test, QA, Staging, and Production servers can share the same setup procedures and configurations.

With these kinds of tools, we can have a system provisioned from zero to production in a few minutes, or we can quickly propagate a configuration change over our whole infrastructure automatically.

Their power is huge and has to be handled with care; as we can automate massive and parallelized setups and configurations of systems; we might automate distributed destructions.

With great power comes great responsibility.

Puppet components

Before diving into installation and configuration details, we need to clarify and explain some Puppet terminology to get the whole picture.

Puppet features a declarative Domain Specific Language (DSL), which expresses the desired state and properties of the managed resources.

Resources can be any component of a system, for example, packages to install, services to start, files to manage, users to create, and also custom and specific resources, such as MySQL grants, Apache virtual hosts, and so on.

Puppet code is written in manifests, which are simple text files with a .pp extension. Resources can be grouped in classes (do not consider them classes as in OOP, they aren't). Classes and all the files needed to define the configurations required are generally placed in modules, which are directories structured in a standard way that are supposed to manage specific applications or system's features (there are modules to manage Apache, MySQL, sudo, sysctl, networking, and so on).

When Puppet is executed, it first runs facter, a companion application, which gathers a series of variables about the system (IP address, hostname, operating system, and MAC address), which are called facts and are sent to the Master.

Facts and user-defined variables can be used in manifests to manage how and what resources to provide to clients.

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.

The Master parses all the DSL code and produces a catalog, which is sent back to the client (in PSON format, a JSON variant used in Puppet). The production of the catalog is often referred to as catalog compilation.

Once the client receives the catalog, it starts to apply all the resources declared there; packages are installed (or removed), services started, configuration files created or changed, and so on. The same catalog can be applied multiple times, if there are changes on a managed resource (for example, a manual modification of a configuration file) they are reverted back to the state defined by Puppet; if the system's resources are already at the desired state, nothing happens.

This property is called idempotence and is at the root of the Puppet declarative model; since it defines the desired state of a system, it must operate in a way that ensures that this state is obtained whatever are the starting conditions and the number of times Puppet is applied.

Puppet can report the changes it makes on the system and audit the drift between the system's state and the desired state as defined in its catalog.