如何做一个混帐拉/推使用ansible

我正在尝试使用ansible来做一个git pull / push。 我正在一台服务器上运行,希望在远程主机上自动化或编排一个git pull / push。

现在,因为我没有find一个mmodule在可靠的文档网站上做到这一点,我决定使用脚本模块去脚本路线

当它运行脚本中调用的git pull时,这个问题是非常棘手的

任何人都知道如何使用ansible来运行git pull / push?

谢谢

http://docs.ansible.com/git_module.html将为您做到这一点就“拉”而言,只要确保运行该命令的用户具有基于密钥的访问git仓库。

您可以通过将“sudo_user”参数添加到您的任务来指定运行该命令的用户:

 - name: Get stuff from git git: [email protected]:you/your-git-repo.git dest=/opt/git-stuff sudo_user: <your user that has the ssh key> 

有关使用sudo_user的更多信息,请参阅http://docs.ansible.com/playbooks_intro.html