Book Image

Puppet Essentials

By : Felix Frank
Book Image

Puppet Essentials

By: Felix Frank

Overview of this book

<p>With this book, you'll be up and running with using Puppet to manage your IT systems. Dive right in with basic commands so that you can use Puppet right away, and then blitz through a series of illustrative examples to get to grips with all the most important aspects and features of Puppet.</p> <p>Install Puppet, write your first manifests, and then immediately put the Puppet tools to real work. Puppet Essentials reveals the innovative structure and approach of Puppet through step-by-step instructions to follow powerful use cases. Learn common troubleshooting techniques and the master/agent setup as well as the building blocks for advanced functions and topics that push Puppet to the limit, including classes and defined types, modules, resources, and leveraging the flexibility and expressive power implemented by Facter and the Hiera toolchain. Finally, send Puppet to the skies with practical guidance on how to use Puppet to manage a whole application cloud.</p>
Table of Contents (16 chapters)
Puppet Essentials
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Using Hiera in different contexts


You will most likely find yourself in need of some data from Hiera when designing templates for configuration or other files. For example, when building your personal module in order to manage the SSH server, you might want to allow nodes to specify a list of environment variables for the AcceptEnv option.

Tip

Granted, this will most likely be passed as a parameter to a class within such a module. The Hiera data will just be bound to the parameter and be available to the template as a regular Puppet variable. Let's ignore this just to have a contrived example for data retrieval from a template.

The naïve implementation would not work inside the template:

<% # pseudo code!
   vars = hiera('ssh::server::env_vars', [ 'LANG', 'LC_*' ]) -%>
AcceptEnv = <%= vars * ' ' %>

The issue is that this call will be directed at a hiera method in Ruby and not the Puppet function. Templates have a way of accessing Puppet's parser functions, but it takes just a little...