knopki/ansible-timezone — pull request #3 by nickstenning (2014-03-17 10:41:43+00:00)
Title: Use template, not copy, to guarantee idempotency

So, this is a bit more finicky than I first thought. Using the copy
module causes problems. If you specify the timezone var as, say,
"Etc/UTC", then the following will happen:

1. Ansible sets the content of /etc/timezone to "Etc/UTC" (with no
trailing newline), triggering the "update tzdata" handler.
2. "dpkg-reconfigure tzdata" handler will cause the file contents to
change to "Etc/UTC\n" (i.e. with a trailing newline)
3. On subsequent ansible runs, the hash of the file will not match and
so it will be updated *again*, triggering steps 1. (and thus, 2.)
again.

This commit fixes the issue by using a simple template to ensure the
file is created with a trailing newline in the first place. (It seems to
be more-or-less impossible to convince the `content` parameter to the
copy module to accept a literal newline.)