Scenario / Questions

I am trying to do a git pull/push using ansible.
I am running ansible on one server and want to automate or orchestrate a git pull/push on a remote host.

Now since i didn’t find a mmodule to do this on ansible doc website, i decided to go the script route using the script module

The problem is ansible hags when it gets to running the git pull called in the script

Anyone know how to run git pull/push using ansible?


Find below all possible solutions or suggestions for the above questions..

Suggestion: 1

Ansible’s Git Module will do this for you as far as the “pull” is concerned, just make sure that the user that is running the command has key-based access to the git repo.

You can specify the user that the command runs as by adding the “sudo_user” parameter to your task:

- name: Get stuff from git
  git: dest=/opt/git-stuff
  sudo_user: <your user that has the ssh key>

See for more information on using sudo_user.

Suggestion: 2

It should be like:-

- name: pull from git
dest: /root/Development/abc
update: yes
version: master

Note: Here the remote user is root

Suggestion: 3

you can try this

- git:
    repo: ''
    dest: /srv/checkout
    version: release-0.22

full documentation on