How do I pass username and password while using Ansible Git module?


While doing clone, push or pull of a private git repository hosted internally (e.g. on a GitLab instance) with Ansible’s Git module, how do I specify username and password to authenticate with the Git server?

I don’t see any way to do this in the documentation.


You can use something like this:

Note: {{ githubpassword | urlencode }} is used here, if your password also contains special characters @,#,$ etc

Then execute the following playbook:

Note: Make sure you put the credentials in ansible vaults or pass it
secure way

Leave a Reply