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,450 points

recategorized Nov 12, 2018 by Priyaj 1,341 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

answered Jul 13, 2018 by DareDev
• 6,890 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
1,185 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,300 points

edited May 31, 2018 by ajs3033 1,069 views
+15 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 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
4,041 views
+2 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,890 points
2,082 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,890 points
2,849 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP