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..
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: email@example.com:you/your-git-repo.git dest=/opt/git-stuff sudo_user: <your user that has the ssh key>
See https://docs.ansible.com/playbooks_intro.html for more information on using sudo_user.
It should be like:-
- name: pull from git
Note: Here the remote user is root
you can try this
- git: repo: 'https://foosball.example.org/path/to/repo.git' dest: /srv/checkout version: release-0.22
full documentation on https://docs.ansible.com/ansible/latest/modules/git_module.html
Disclaimer: This has been sourced from a third party syndicated feed through internet. We are not responsibility or liability for its dependability, trustworthiness, reliability and data of the text. We reserves the sole right to alter, delete or remove (without notice) the content in its absolute discretion for any reason whatsoever.