Salt: Require packages installed before executing a formula

0 votes

I have got some formulas that rely on some packages. Right now I'm doing something like this:
init.sls

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

Is this the best approach or is there any other better way of doing it?

Jul 13, 2018 in Other DevOps Questions by DragonLord999
• 8,380 points

recategorized Nov 12, 2018 by Priyaj 53 views

1 answer to this question.

0 votes

You're on the right path. Using require_in like you've shown in your example is the correct way of ensuring those packages are installed before you execute brrap.sls etc. All the _in requistites work in the similar fashion. The require_in requisite is very useful when assigning a require in a different sls file.

So far as your brrap.sls blah.sls states do not have to know the additional components required(foo and bar packages) when it is set up, what you've done is perfectly fine.

On the other hand if you brrap.sls and blah.sls do require the foo and bar package to be installed, you should instead try and create a require requisite from brrap.sls and blah.sls.

take this example

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   

Note that httpd server will only start if php is installed

Got through the docs here.

answered Jul 13, 2018 by DareDev
• 6,810 points

Related Questions In Other DevOps Questions

0 votes
1 answer

How do I set variable if a specific package version is installed in CFEngine?

Here is what you can do.Just use packagesmatching to ...READ MORE

answered Jul 12, 2018 in Other DevOps Questions by Atul
• 10,240 points
93 views
0 votes
1 answer

Setting up CICD on a local server

As to how to integrate git repo ...READ MORE

answered May 31, 2018 in Other DevOps Questions by ajs3033
• 7,280 points

edited May 31, 2018 by ajs3033 34 views
+13 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 26, 2018 in DevOps & Agile by DragonLord999
• 8,380 points
219 views
0 votes
1 answer
0 votes
1 answer

Using conditional to execute a command in salt

You can use unless inside your state ...READ MORE

answered Jul 23, 2018 in Other DevOps Questions by DareDev
• 6,810 points
109 views
0 votes
1 answer

How to get issues count based on rules in a sonar project?

There are API docs in the footer ...READ MORE

answered May 4, 2018 in Other DevOps Questions by DareDev
• 6,810 points
454 views