我想运行一个使用salt目录中的文件的命令(cmd.run
),例如:
fly_set_{{ pipeline }}:
cmd.run:
- name: |
fly -t ci set-pipeline -p {{ pipeline }} -c pipeline.yml -l credentials.yml
- require:
- cmd: fly_login_{{name}}
- file: /etc/concourse/teams/builds/{{ pipeline }}/pipeline.yml
- file: /etc/concourse/teams/builds/{{ pipeline }}/credentials.yml
这是正确的方法还是我需要先做这个?
file:
managed:
- source: salt://concourse/teams/builds/{{ pipeline }}/pipeline.yml
答案 0 :(得分:3)
我不确定你想要实现什么,但如果你的命令依赖于多个文件,那么正确的方法是:
/etc/concourse/teams/builds/{{ pipeline }}/pipeline.yml:
file.managed:
- source: salt://concourse/teams/builds/{{ pipeline }}/pipeline.yml
/etc/concourse/teams/builds/{{ pipeline }}/credentials.yml:
file.managed:
- source: salt://concourse/teams/builds/{{ pipeline }}/credentials.yml
fly_set_{{ pipeline }}:
cmd.run:
- name: |
fly -t ci set-pipeline -p {{ pipeline }} -c pipeline.yml -l credentials.yml
- require:
- file: /etc/concourse/teams/builds/{{ pipeline }}/pipeline.yml
- file: /etc/concourse/teams/builds/{{ pipeline }}/credentials.yml
前两个file.managed
指令将确保这两个文件都存在于minion上。 require
中的cmd.run
指令将确保在执行命令之前文件存在于minion 上。