我有一个非常简单的用例正在尝试运行:
我需要从主服务器下载并安装一些 tar.gz 源包,然后运行脚本来编译并安装它们所有。
我意识到这可能是一个基本问题,但任何指点都将不胜感激。
/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
答案1
想通了,以防将来对某人有帮助:
/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
答案2
最近版本的 salt 默认开启了“状态自动排序”,从而消除了大部分这种麻烦。 http://docs.saltstack.com/ref/states/ordering.html#state-auto-ordering
也就是说,您的解决方案是明确说明要求的更好的解决方案。