在檢查模式下,我想在服務器中顯示當前提交。我使用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