Chapter 8. Expressions and Logic

A young man should read five hours in a day, and so may acquire a great deal of knowledge.

— Samuel Johnson

In this chapter, you'll learn how to make choices in your Puppet manifests, how to do arithmetic, logic, and string operations in the Puppet language, and how to use regular expressions to match patterns in strings. You'll also find out about some useful Puppet data types: arrays and hashes.

Expressions and Logic


It's useful to be able to do different things in a manifest depending on the value of some variable or expression. Puppet provides several ways to do this. The first is the if statement.

If statements

An if ...

Get Puppet 3 Beginner's Guide now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.