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:

42
true
'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
notice($value)

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 O’Reilly online learning.

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