Search code examples
puppet

What does 'if $variable {}' mean in Puppet?


If I have the following if statement in puppet:

if $variable {

   do something

}

What does this mean? Is it if $variable is true? If it exists? If it is defined?


Solution

  • Read the documentation.

    “If” statements “If” statements take a boolean condition and an arbitrary block of Puppet code, and will only execute the block if the condition is true. They can optionally include elsif and else clauses.

    https://docs.puppet.com/puppet/latest/reference/lang_conditional.html#if-statements