Copy Module doesnt override destination file

hi,

so this is what I have in my yml file:

  • name: Copy War File

copy: src=externaluserwebapi.war dest=/usr/share/tomcat7/webapps

become: True

become_method: sudo

and this is what I get when I run playbook:

ok: [10.1.33.227] => {“changed”: false, “checksum”: “c93572d33bd0555a87341380ac389382c225a92d”, “dest”: “/usr/share/tomcat7/webapps/externaluserwebapi.war”, “gid”: 0, “group”: “root”, “invocation”: {“module_args”: {“backup”: false, “content”: null, “delimiter”: null, “dest”: “/usr/share/tomcat7/webapps/externaluserwebapi.war”, “directory_mode”: null, “follow”: false, “force”: true, “group”: null, “mode”: null, “original_basename”: “externaluserwebapi.war”, “owner”: null, “regexp”: null, “remote_src”: null, “selevel”: null, “serole”: null, “setype”: null, “seuser”: null, “src”: “/home/ec2-user/.ansible/tmp/ansible-tmp-1470673998.42-22221732776252/source”, “validate”: null}}, “md5sum”: “ba5224fb84a5f82d5fa7b8a8f83c4b2e”, “mode”: “0644”, “owner”: “root”, “size”: 17027813, “src”: “/home/ec2-user/.ansible/tmp/ansible-tmp-1470673998.42-22221732776252/source”, “state”: “file”, “uid”: 0}

Not sure why but copy module is not overriding the script in destination directory.I read that by default it is force=yes.Please help.

The reason is because the files is identical.

To debug you could add this tasks.

Add this two task before "Copy War File"
- stat:
     path=externaluserwebapi.war
   delegate_to: localhost
   register: result

- debug: var=result

and add this two task after "Copy War File"
- stat:
     path=/usr/share/tomcat7/webapps
   register: result

- debug: var=result

Thanks Kai.Yes,the files are identical.But there should be some way to overwrite it.Is there any way?

No, this is part of Ansibles idempontecy[1], it does not do any changes if the files is identical.
Why do you want to overwrite the file if it's identical, overwrite it will have no function since nothing will change.

[1] https://docs.ansible.com/ansible/glossary.html#term-idempotency

k got it.thx.