gpt4 book ai didi

git - Ansible git 模块 rev-parse

转载 作者:太空狗 更新时间:2023-10-29 13:27:13 26 4
gpt4 key购买 nike

您好,我想执行以下任务以在本地提取最新的提交 ID:

  - name: get latest git commit id
local_action: "command git rev-parse HEAD"
register: git_commit_id

但我收到了警告,因为我正在使用 command。由于 git 是一个可靠的核心模块:http://docs.ansible.com/ansible/git_module.html

如何使用 git 模块执行此操作?

最佳答案

如果你把它放在你的 vars 文件中:

base: "{{ lookup('pipe', 'git rev-parse --show-toplevel') }}"

然后在您的剧本中使用变量 {{base}} 来执行此操作。

关于git - Ansible git 模块 rev-parse,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36991049/

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