gpt4 book ai didi

git - 如何在 ansible 检查模式下运行 shell 命令?

转载 作者:IT王子 更新时间:2023-10-29 00:59:13 26 4
gpt4 key购买 nike

在检查模式下,我想显示服务器中的当前提交。我正在使用 shell 命令 (git rev-parse HEAD) 来注册变量,然后打印/调试它,但 ansible 在检查模式下会跳过 shell 命令。

有没有办法将 shell 命令标记为可以在检查模式下安全运行?

或者任何 ansible 模块来做我想做的事?我检查了 git 的模块,但它看起来只是检查。

如有任何意见,我们将不胜感激。

最佳答案

从 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

关于git - 如何在 ansible 检查模式下运行 shell 命令?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30139810/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com