gra*_*lor 10 configuration-management ansible centos7
我正在尝试使用 ansible 进行 git pull/push。我在一台服务器上运行 ansible,并希望在远程主机上自动化或编排 git pull/push。
现在,由于我没有在 ansible doc 网站上找到 mmodule 来执行此操作,因此我决定使用脚本模块走脚本路线
当它开始运行脚本中调用的 git pull 时,问题是 ansible hags
有人知道如何使用 ansible 运行 git pull/push 吗?
谢谢
Pro*_*ken 18
就“拉”而言,Ansible 的 Git 模块将为您执行此操作,只需确保运行该命令的用户具有对 git 存储库的基于密钥的访问权限。
您可以通过将“sudo_user”参数添加到您的任务来指定命令运行的用户:
- name: Get stuff from git
git:
repo: git@github.com:you/your-git-repo.git
dest: /opt/git-stuff
sudo_user: <your user that has the ssh key>
Run Code Online (Sandbox Code Playgroud)
有关使用 sudo_user 的更多信息,请参阅https://docs.ansible.com/playbooks_intro.html。
它应该是这样的:-
tasks:
- name: pull from git
git:
repo: git@gitlab.com:xyz.git
dest: /root/Development/abc
update: yes
version: master
注意:这里远程用户是root
| 归档时间: |
|
| 查看次数: |
54420 次 |
| 最近记录: |