Ansible - Add and commit a file to Git using the shell module
by
Jeremy Canfield |
Updated: April 01 2024
| Ansible articles
If you are not familiar with modules, check out Ansible - Getting Started with Modules.
The git module does not support common git tasks such as git add, git remove, and git commit. The shell module can be used to perform these other git tasks.
---
- hosts: all
tasks:
- name: add bar.txt to foo.git
ansible.builtin.shell: git add bar.txt
args:
chdir: /path/to/cloned/git/repo
...
AVOID TROUBLE
If "peer's certificate issuer is not recognized" is being returned, the GIT_SSL_NO_VERIFY variable can be set to true before issuing a git command.
---
- hosts: all
tasks:
- name: add bar.txt to foo.git
ansible.builtin.shell: export GIT_SSL_NO_VERIFY=true; git add bar.txt
args:
chdir: /path/to/cloned/git/repo
...
Did you find this article helpful?
If so, consider buying me a coffee over at