【发布时间】:2020-11-05 00:35:31
【问题描述】:
开发人员刚刚完成了对 Dev 服务器上的某些代码的更改,该服务器使用 Ansible 从 Azure git 存储库收到了 git clone。
在 Ansible 任务中必须使用什么特定语法来
add、commit和push开发人员将代码从 Dev 服务器更改回同一 Azure git 存储库? p>
以下是@garylopez贡献的git clone Ansible 任务:
---
- name: Clone repo playbook
hosts: dev
vars_prompt:
- name: "git_password"
prompt: "Password for 'https://OrganizationName@dev.azure.com'"
private: yes
tasks:
- name: Clone a repo
git:
repo: https://{{ git_user | urlencode }}:{{ git_password | urlencode }}@dev.azure.com/OrganizationName/ProjectName/_git/RepositoryName
dest: /src/RepositoryName
我们检查了 Ansible git 模块的 docs,但没有看到样板示例。
如果 Ansible git 模块不支持这一点,我们想象有人可能会在 Ansible 任务中诉诸某种 shell 命令解决方案。但我们在这里提出问题,希望可以在答案中提供最佳实践类型的方法。
【问题讨论】:
-
git模块只会让您获得远程存储库的全新克隆以用于部署目的。通过添加到现有模块或提供新模块(一个示例:github.com/ansible-collections/community.general/pull/168)来向 ansible 提供添加/提交/推送功能已经有多种尝试。但据我所知,没有人能将其释放。现在,您将不得不走命令/shell 路线。
标签: git ansible azure-repos