Book Image

Puppet 5 Essentials - Third Edition

By : Felix Frank
Book Image

Puppet 5 Essentials - Third Edition

By: Felix Frank

Overview of this book

Puppet is a configuration management tool that allows you to automate all your IT configurations, giving you control over what you do to each Puppet Agent in a network, and when and how you do it. In this age of digital delivery and ubiquitous Internet presence, it's becoming increasingly important to implement scaleable and portable solutions, not only in terms of software, but also the system that runs it. This book gets you started quickly with Puppet and its tools in the right way. It highlights improvements in Puppet and provides solutions for upgrading. It starts with a quick introduction to Puppet in order to quickly get your IT automation platform in place. Then you learn about the Puppet Agent and its installation and configuration along with Puppet Server and its scaling options. The book adopts an innovative structure and approach, and Puppet is explained with flexible use cases that empower you to manage complex infrastructures easily. Finally, the book will take readers through Puppet and its companion tools such as Facter, Hiera, and R10k and how to make use of tool chains.
Table of Contents (10 chapters)

Leveraging the new template engine

In Chapter 6, The Puppet Beginners Advanced Parts, we introduced templates and the ERB template engine. In Puppet 4, an alternative was added: the EPP template engine. The major differences between the template engines are as follows:

  • In ERB templates, you cannot specify a variable in Puppet syntax ($variable_name)
  • ERB templates will not accept parameters
  • In EPP templates, you will use the Puppet DSL syntax instead of Ruby syntax

The EPP template engine requires scoped variables from modules:

# motd file - managed by Puppet 
This system is running on <%= $::operatingsystem %> 

The manifest defines the following local variable: <%= $motd::local_variable %>. The EPP templates also have a unique extension: they can take typed parameters.
To make use of this, a template has to start with a parameter declaration block:

<%- | String...