[英]How to run a shell command in ansible's check mode?
在检查模式下,我想在服务器中显示当前提交。 我正在使用 shell 命令 ( git rev-parse HEAD
) 来注册变量,然后打印/调试它,但 ansible 在检查模式下跳过 shell 命令。
无论如何将shell命令标记为在检查模式下运行是安全的?
或者任何 ansible 模块来做我想做的事? 我检查了 git 的模块,但它看起来只是结帐。
任何输入将不胜感激。
从 Ansible 2.2 开始, 正确的做法是使用check_mode: no
:
tasks:
- name: this task will make changes to the system even in check mode
command: /something/to/run --even-in-check-mode
check_mode: no
找到了答案。 您必须将always_run: True
添加到任务中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.