我试过这个:
- command: ./configure chdir=/src/package/
- command: /usr/bin/make chdir=/src/package/
- command: /usr/bin/make install chdir=/src/package/
这有效,但我希望有更简洁的东西。
所以我尝试了这个:
from: https://stackoverflow.com/questions/24043561/multiple-commands-in-the-same-line-for-bruker-topspin https://stackoverflow.com/questions/24043561/multiple-commands-in-the-same-line-for-bruker-topspin这给了我“没有这样的文件或目录”
- command: ./configure;/usr/bin/make;/usr/bin/make install chdir=/src/package/
我也尝试过这个:https://u.osu.edu/hasnan.1/2013/12/16/ansible-run-multiple-commands-using-command-module-and-with-items/ https://u.osu.edu/hasnan.1/2013/12/16/ansible-run-multiple-commands-using-command-module-and-with-items/
但我找不到正确的语法:
- command: "{{ item }}" chdir=/src/package/
with_items:
./configure
/usr/bin/make
/usr/bin/make install
这不起作用,说存在报价问题。
要使用 ansible 运行多个 shell 命令,您可以使用shell具有多行字符串的模块(注意pipe after shell:
),如本例所示:
- name: Build nginx
shell: |
cd nginx-1.11.13
sudo ./configure
sudo make
sudo make install
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)