3

This is more of a clarification request.

I have two formulas that rely on a bunch of packages being installed by the init.sls formula before they're run.

At the moment I have something like the below. I was wondering if anyone could confirm this is the correct approach, or whether someone could indeed offer a better approach.

init.sls

install_packages:
  pkg.installed:
    - pkgs:
        - foo
        - bar
    - require_in:
      - sls: brrap
      - sls: blah

So would doing this ensure that the above packages are installed before brrap.sls and blah.sls are executed?

Thanks

grinferno
  • 524
  • 8
  • 23

1 Answers1

4

Yes, using the require_in requisite in your example will ensure the packages are installed before brrap.sls and blah.sls are executed.

All of the _in requisites work in the same way: they result in a normal requisite in the targeted state. The require_in statement is particularly useful when assigning a require in separate sls files.

As long as the brrap.sls and blah.sls states do not need to be aware of the additional components (the foo and bar packages) that require it when it is set up, your configuration is fine. If the brrap.sls and blah.sls states do require the foo and bar packages to be installed in all the cases, it might be a more straightforward solution to create a require requisite from the brrap.sls and blah.sls states.

Take for instance the following state http.sls:

httpd:
  pkg.installed:
    - name: httpd
  service.running:
    - name: httpd

On some of your minions you might want to use the http.sls, and on others you might want to use the http.sls and the php.sls states:

include:
  - http

php:
  pkg.installed:
    - name: php
    - require_in:
      - service: httpd   

Now the httpd server will only start if php is verified to be installed.

Take a look at the requisites and other global state arguments documentation for the full example.

Roald Nefs
  • 1,302
  • 10
  • 29