March 2017
Beginner to intermediate
925 pages
18h 11m
English
Another kind of expression you can test in if statements and other conditionals is the regular expression. A regular expression is a powerful way to compare strings using pattern matching.
This is one example of using a regular expression in a conditional statement. Add the following to your manifest:
if $::architecture =~ /64/ {
notify { '64Bit OS Installed': }
} else {
notify { 'Upgrade to 64Bit': }
fail('Not 64 Bit')
}Puppet treats the text supplied between the forward slashes as a regular expression, specifying the text to be matched. If the match succeeds, the if expression will be true and so the code between the first set of curly braces will be executed. In this example, ...
Read now
Unlock full access