Search code examples
salt-project

SaltStack: conditional include: Error if empty


I have a conditional include which looks like this:

include:
{% if CONDITION-A %}
  - foo.bar
{% endif %}
{% if CONDITION-B %}
  - blu.bla
{% endif %}

This works in most cases.

But it fails if CONDITION-A and CONDITION-B are false.

How to handle this?


Solution

  • I use this pattern now:

    include:
      - dummy
    {% if CONDITION-A %}
      - foo.bar
    {% endif %}
    {% if CONDITION-B %}
      - blu.bla
    {% endif %}
    

    dummy.sls:

    dummy-no-op:
      test.nop
    

    Not nice, but works.

    Better (simpler, more obvious) answers are welcome.

    Docs for test.nop