1
votes

My sls file looks like this:

init.sls

include:
  - .packages
  - .user_and_group

packages.sls

monitoring_packages:
  pkg.installed:
    - pkgs:
      - git

user_and_group.sls

monitoring__group:
  group.present:
    - name: myuser

For some strange reason the state monitoring__group from the include "user_and_group" get executed before installing git.

Question

How can I tell salt to install the packages first?

1

1 Answers

0
votes

init.sls (unchanged)

include:
  - .packages
  - .user_and_group

packages.sls (unchanged)

monitoring_packages:
  pkg.installed:
    - pkgs:
      - git

user_and_group.sls (added require)

monitoring__group:
  group.present:
    - name: myuser
  require:
    - sls: packages

Docs

I found the answer here: https://docs.saltstack.com/en/latest/ref/states/requisites.html#require-an-entire-sls-file

As of Salt 0.16.0, it is possible to require an entire sls file.

One question remains

This solves my problem. But one question remains: Why did salt execute the first version (see question) not in the top-to-bottom order? If you know it, please leave a comment.