0

I want to check, if a given string is inside an array and if it isn't, I want to execute the code inside. However the in function seems to work with if only, when I use unless I get the following error.

Could not parse for environment production: Syntax error at 'in'; expected '}'

Code looks like this:

$string = 'abc'
$array = ['abc', 'def', 'ghi']

unless $string in $array {
  do xxx
}

what is going on? I use Puppet 2.7

1 Answer 1

1

Your code works with Puppet 3.7.

2.7 seems to have no unless at all.

Try an if ! x construct, or work around the issue using

if $foo in $bar {
    # noop
} else {
    # your code here
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.