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 which that 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' == 'foo') notice('foo' in 'foobar') notice('foo' in ['foo', 'bar']) notice('foo' in { 'foo' => 'bar' }) notice(...