Bootstrap FreeKB - Ansible - Add and commit a file to Git using the shell module
Ansible - Add and commit a file to Git using the shell module

Updated:   |  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
    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
    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 Buy Me A Coffee



Comments


Add a Comment


Please enter 3e55f6 in the box below so that we can be sure you are a human.