'git add, commit, push using Ansible to Azure Repo

A developer just finished making changes to some code on a Dev server that received a git clone from an Azure git Repository using Ansible.

What specific syntax must be used in Ansible tasks to add, commit, and push the developer's changed code from the Dev server back to the same Azure git Repository?

The following is the git clone Ansible task that was contributed by @garylopez:

--- 
- name: Clone repo playbook
  hosts: dev

  vars_prompt: 
    - name: "git_password" 
      prompt: "Password for 'https://[email protected]'"
      private: yes 

  tasks:
  - name: Clone a repo 
    git:
      repo: https://{{ git_user | urlencode }}:{{ git_password | urlencode }}@dev.azure.com/OrganizationName/ProjectName/_git/RepositoryName
      dest: /src/RepositoryName  

We have examined the Ansible git module's docs, but do not see a boilerplate example.

We imagine someone might resort to some sort of shell command solution in Ansible tasks if the Ansible git module does not support this. But we are asking here hoping that a best practice type approach might be offered in an answer.



Solution 1:[1]

you can use git module for checkout and shell command for add commit push https://docs.ansible.com/ansible/latest/collections/ansible/builtin/git_module.html

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Rifwan Jaleel