I found a single GIT command to do that.

git push origin <tag/branch> --repo https://username:[email protected]

On Tuesday, 4 October 2016 22:51:34 UTC+2, Alexander H. Laughlin wrote:
>
> I think something like the below would work to solve your problem with the 
> variable interpolation.
>
> - name: Push git commits with local variables.
>
>   hosts: localhost
>
>   vars:
>
>     username: git_username
>
>     password: git_password
>
>   tasks:
>
>     - name: Set origin to include username and password.
>
>       shell: "git remote set-url origin https://{{ git_username }}:{{ 
> git_password }}@yourhost.com/storage/repo.git"
>
>     - name: Push to origin.
>
>       shell: "git push origin branch"
>
> That is, if you can safely transmit the passwords via https. If you're 
> using http this would be incredibly unsafe. 
>
> You could also look at setting the credential.helper variable in git (`git 
> config --global credential.helper store`), but that's beyond the scope of 
> this mailing list.
>
> On Tuesday, October 4, 2016 at 8:21:37 AM UTC-7, ishan jain wrote:
>>
>> Seems like there is isn't any module in Ansible which can commit back to 
>> a GIT repo. My case is such that i am allowing the user to create a new 
>> branch in any of our several repositories and with the help of templates, 
>> generate some necessary files, all this via ansible. I am able to clone the 
>> repo (even a branch/tag) via GIT module, create a new branch with shell 
>> module, populate it with templates, but now i need to push the new branch 
>> and its contents and this is where i am stuck. GIT push would prompt for 
>> username and password which is something i have in the variables but don't 
>> know how to use in Ansible shell command. Any ideas how to proceed here ?
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/1bf186f4-cbf4-4d8d-b9e8-b6e961b70767%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to