Introducing expressions

Variables are not the only things in Puppet that have a value. Expressions also have a value. The simplest expressions are just literal values:

'Oh no, not again.'

You can combine numeric values with arithmetic operators, such as +, -, *, and /, to create arithmetic expressions, which have a numeric value, and you can use these to have Puppet do calculations (expression_numeric.pp):

$value = (17 * 8) + (12 / 4) - 1

The most useful expressions, though, are those which evaluate to true or false, known as Boolean expressions. The following is a set of examples of Boolean expressions, all of which evaluate to true (expression_boolean.pp):

notice(9 < 10) notice(11 > 10) notice(10 >= 10) notice(10 <= 10) notice('foo' ...

Get Puppet 4.10 Beginner's Guide Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.