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

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.

- 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.

- 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

Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.





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