module copy with content reports changes on every run

Hi,

if i run a task with this:
copy: dest=/etc/timezone content=“Europe/Berlin” owner=root group=root mode=0644
it reports on every run changes.

Verbose output of two runs:
changed: [xxx] => {“changed”: true, “checksum”: “d34f419876c03cf85365d9102477a4f5791451ae”, “dest”: “/etc/timezone”, “gid”: 0, “group”: “root”, “md5sum”: “f047a3577fcd6af23b47814293e293c0”, “mode”: “0644”, “owner”: “root”, “size”: 13, “src”: “/home/xxx/.ansible/tmp/ansible-tmp-1422009942.63-92526854461725/source”, “state”: “file”, “uid”: 0}

changed: [xxx] => {“changed”: true, “checksum”: “d34f419876c03cf85365d9102477a4f5791451ae”, “dest”: “/etc/timezone”, “gid”: 0, “group”: “root”, “md5sum”: “f047a3577fcd6af23b47814293e293c0”, “mode”: “0644”, “owner”: “root”, “size”: 13, “src”: “/home/xxx/.ansible/tmp/ansible-tmp-1422009987.9-92475302492184/source”, “state”: “file”, “uid”: 0}

The md5sum of the transfered content always doesn’t match the file content.

Control host: Ubuntu
Destination Host: Debian
ansible 1.8.2

Chris

Your problem is in the way you are using the content argument. Your string does not include a trailing newline, and when you run dpkg-reconfigure to update the timezone, dpkg-reconfigure will notice that there is no trailing newline and “fix it”. So every time your task runs, you are removing the trailing newline that dpkg-reconfigure adds to that file.

There is some discussion about this at https://github.com/ansible/ansible/issues/5715