O'Reilly logo

Puppet 4.10 Beginner's Guide - Second Edition by John Arundel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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' ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required