Lab – creating and testing templates containing loops and conditions
In this lab, we will bring together everything you have seen in this chapter so far, testing and validating some example templates and creating a template using logic and iteration:
- Download the template files at https://github.com/PacktPublishing/Puppet-8-for-DevOps-Engineers/tree/main/ch07/templates_to_check and validate and parse each of them to ensure the templates produce the following (
<>
shows where interpolation needs to happen):- “This template was run on a machine with <# number of cpus of your machine> cpus”
- “The custom fact pack.lab was < set to content of fact or the string ‘not set’ > “
Hint
You would want to use the getvar
function to test the fact and test it by passing in a hash, setting it when parsing to test it.
- “The system uptime is < showing only days hours mins if they are non zero > “...