I have a following puppet module

class base ($someBoolean=false,){exec { 'Do something':command => '/usr/bin/someStuff',timeout => (someBoolean) ? 100000000 : 300}}

The timeout => () ? : is enssentially what I want to do, but what is the correct syntax to do it? Is it possible at all?

1

Best Answer


Puppet's version of the ternary operator is the more general "selector". The syntax for your case looks like this:

exec { 'Do something':command => '/usr/bin/someStuff',timeout => $someBoolean ? { true => 100000000, default => 300 }}

The control expression ($someBoolean in the above) can in fact be any expression that produces a value, and any number of corresponding cases can be provided.