ansible 如何 执行git pull 远程主机

需求:通过 ansible 用一条命令 在git 目录外的目录,执行git pull 目标目录
注意:是通过ansible 控制远程git pull

update:

clipboard.png
配了3个host 代码路径都一样,但是只有一个能更新,这是为什么呢,
求指点

阅读 6.4k
3 个回答

参见https://stackoverflow.com/que...

Starting git 1.8.5 (Q4 2013), you will be able to "use a Git command, but without having to change directories".

Just like "make -C <directory>", "git -C <directory> ..." tells Git to go there before doing anything else.

git --work-tree=/home/www/project --git-dir=/home/www/project/.git pull

https://www.kancloud.cn/hiyan...

---
- name: module git test
  hosts: s.hi.com
  vars:
    repo_url: git@git.coding.net:xxxx/ansiblebook.git
    dest_path: /tmp/repo
  tasks:
  - name: checkout repository on the host
    git: repo={{ repo_url }} dest={{ dest_path }} accept_hostkey=yes
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题