Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have a very simple use case that I'm trying to get going:

I need to download and install a few tar.gz source packages from the master and then run a script to compile and install all of them.

I realize this is probably a basic question, but any pointers will be appreciated.

/usr/local/src/source1.tar.gz:
  file.managed:
    - source: salt://sources/source1.tar.gz
    - user: root
    - group: root
    - mode: 644

/usr/local/src/source2.tar.gz:
  file.managed:
    - source: salt://sources/source2.tar.gz
    - user: root
    - group: root
    - mode: 644

/usr/local/src/source3.tar.gz:
  file.managed:
    - source: salt://sources/source3.tar.gz
    - user: root
    - group: root
    - mode: 644

//I need something like this, but am not sure how to do it
compile_and_install:
  - require: /usr/local/src/source1.tar.gz
  - require: /usr/local/src/source2.tar.gz
  - require: /usr/local/src/source3.tar.gz
  cmd.script:
    - source: salt://scripts/compile_and_install.sh
    - user: root
    - group: root
    - shell: /bin/bash
share|improve this question

2 Answers 2

up vote 3 down vote accepted

Figured it out, in case it helps someone in the future:

/usr/local/src/source1.tar.gz:
  file.managed:
    - source: salt://sources/source1.tar.gz
    - user: root
    - group: root
    - mode: 644

/usr/local/src/source2.tar.gz:
  file.managed:
    - source: salt://sources/source2.tar.gz
    - user: root
    - group: root
    - mode: 644

/usr/local/src/source3.tar.gz:
  file.managed:
    - source: salt://sources/source3.tar.gz
    - user: root
    - group: root
    - mode: 644

compile_and_install:
  cmd.script:
    - require:
      - file: /usr/local/src/source1.tar.gz
      - file: /usr/local/src/source2.tar.gz
      - file: /usr/local/src/source3.tar.gz
    - source: salt://scripts/compile_and_install.sh
    - user: root
    - group: root
    - shell: /bin/bash
share|improve this answer

Recent versions of salt have taken much of this pain away with State Auto Ordering on by default. http://docs.saltstack.com/ref/states/ordering.html#state-auto-ordering

That said, your solution is the better one of explicitly stating the requirement.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.