sj80
sj80

Reputation: 11

Jinja (salt): multiple if conditions

I'm looking for a way to not perform tasks on certain hosts. I tried different ways with Jinja, but it doesn't work.

This works, but only for one host:

{% if grains['id'] != 'node300.example.com' %}
  SALT TASKS
{% endif %}

I tried that and some variations, but it didn't work:

{% if ( (grains['id'] != 'node300.example.com') or
       (grains['id'] != 'node303.example.org') or
       (grains['id'] != 'node208.example.net') ) %}
  SALT TASKS
{% endif %}

Upvotes: 0

Views: 1575

Answers (1)

sj80
sj80

Reputation: 11

I got a tip from IRC. This works:

{% if grains['id'] not in ['node300.example.com',
                           'node303.example.org',
                           'node208.example.net'] %}
  SALT TASKS
{% endif %}

Upvotes: 1

Related Questions