在检查模式下,我想在服务器中显示当前提交。我使用shell命令(git rev-parse HEAD
)来注册变量,然后在检查模式下打印/调试它,但无法跳过shell命令。如何在ansible的检查模式下运行shell命令?
有没有办法将shell命令标记为在检查模式下安全运行?
或者任何可以做我想要的模块吗?我检查了git的模块,但它看起来只是它的结账。
任何输入,将不胜感激。
在检查模式下,我想在服务器中显示当前提交。我使用shell命令(git rev-parse HEAD
)来注册变量,然后在检查模式下打印/调试它,但无法跳过shell命令。如何在ansible的检查模式下运行shell命令?
有没有办法将shell命令标记为在检查模式下安全运行?
或者任何可以做我想要的模块吗?我检查了git的模块,但它看起来只是它的结账。
任何输入,将不胜感激。
找到了答案。您必须将always_run: True
添加到该任务。
从Ansible 2.2开始,the right way to do it是使用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