BUG: This is some weird stuff. Copy module changing file

rpm -q ansible

ansible-2.4.1.0-1.el7.ans.noarch

I was having problems after running one of my playbooks with an unknown module. I narrowed it down to a task in my playbook. Can someone explain this? Seems like a bug.

`

I filed a bug:

https://github.com/ansible/ansible/issues/32445

force: no prevents a copy if the dest file exists

Yes, but the contents of the file change… the force option is set that way on purpose so I don’t overwrite any local changes if they exist.

Ansible is stateless. So it doesn't know if the remote file exists in
the way you have it because you changed it on the remote system or
because a previous ansible run dropped that version of hte file there.
If you want Ansible to ensure that the remote file matches what you
have at your source then you must have force: yes. If you want
ansible to always respect remote changes then you have force: no.

You can come up with your own method to track remote state to
determine whether to overwrite the file or not (by taking a hash of
previous files pushed out by ansible and saving it somewhere for
comparison in the future) you certainly can write several tasks to
take care of that but that is outside of the scope of what's built
into Ansible.

-Toshio

I set force to yes, and it is still happening.

OK, I see it is grabbing the file from my ansible server, and copying it to the managed server. I was expecting it to copy it from the managed server to the managed server… now I just need to figure out the right syntax for that.

Done, the key is to add:

remote_src: yes