My git workspace is dirty, there are some local modifications. When I use command git pull origin master
it works fine because there is no conflict.
But when I'm trying to use Ansible
like
git: repo=xxxx dest=xxx version={{branch}}
I got error:
Local modifications exist in repository (force=no)
If I add force=yes
, then I will lose my local modifications.
What can I do to keep my local changes and pull latest commit from git by using Ansible git module.
The ansible-pull command, which is part of Ansible, allows you to download your configuration from a Git repository and apply it immediately. You won't need to maintain a server or an inventory list; you simply run the ansible-pull command, feed it a Git repository URL, and it will do the rest for you.
You cannot achieve it using the git module.
Ansible checks the result of:
git status --porcelain
and aborts task execution if there are local changes in tracked files, unless force
parameter is set to true
.
You can use something like :
git: repo=xxxx dest=xxx version={{branch}} force=no
ignore_errors: yes
see https://docs.ansible.com/ansible/latest/user_guide/playbooks_error_handling.html#ignoring-failed-commands
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With