Salt-Stack require statement

1.1k views Asked by At

I've started playing with Salt. I could not find any info on how to make a state depend on multiple other states.

state_a:
  module.run:
    - name: my.module
    - m_name: name_a

state_b:
  module.run:
    - name: my.module
    - m_name: name_b

state_c:
  module.run:
    - name: my.module
    - m_name: name_c

    - require:
      - module: ...

How can I make state_c to require both state_a and state_b?

Bonus question: What is the rationale behind using Key: Single Value structure for defining dependencies in Salt?

1

There are 1 answers

1
Andrew On BEST ANSWER

This should work in most cases:

state_c:
  module.run:
    - name: my.module
    - m_name: name_c
    - require:
      - module: state_a
      - module: state_b

Also, regarding Salt's usage of lists of single-value dicts instead of flat dictionaries: I think it's partly because of cases like this one where you need multiple identical keys, and partly as a way to simulate an ordereddict for cases when order matters. I'm not a salt developer, though.