Templating, Iterating, and Conditionals
This chapter will cover advanced structures for the Puppet language, including templates that enable the insertion of variables into templated files. The two formats available in Puppet, Embedded Ruby (ERB) templates, which are based on native Ruby templating, and Embedded Puppet (EPP) templates, which are modern Puppet language-based templates, will be discussed, highlighting the differences between the two and the core advantages of using EPP over ERB.
Additionally, the chapter will delve into the use of iteration and loops in Puppet, showing how iterative functions are used with sections of code known as lambdas in Puppet instead of more traditional loop
keywords of other languages. Finally, the chapter will examine the different types of conditional statements available in Puppet, including if
, case
, and unless
statements, which are typical of any programming language, and the Puppet-specific selector, which allows a value on a key or...