---
- name: Set Timezone
  copy:
    content: '{{ timezone | default("Etc/UTC") }}\n'
    dest:    /etc/timezone
    owner:   root
    group:   root
    mode:    0644
  sudo: yes
  notify: Update Timezone

- name: Check Localtime
  command: diff /etc/localtime /usr/share/zoneinfo/{{ timezone | default("Etc/UTC") }}
  register: localtime_diff
  changed_when: localtime_diff.stdout != ""

- name: Set Local Time
  command: mv /usr/share/zoneinfo/{{ timezone | default("Etc/UTC") }} /etc/localtime
  sudo: yes
  notify: Update Timezone
  when: localtime_diff.stdout != ""

---
- name: Set Timezone
  copy:
    content: '{{ timezone | default("Etc/UTC") }}\n'
    dest:    /etc/timezone
    owner:   root
    group:   root
    mode:    0644
  sudo: yes
  notify: Update Timezone

- name: Check Localtime
  command: diff /etc/localtime /usr/share/zoneinfo/{{ timezone | default("Etc/UTC") }}
  register: localtime_diff
  changed_when: localtime_diff.stdout != ""
  failed_when: >
    localtime_diff.rc == 2 and
    localtime_diff.stdout != "Binary files /etc/localtime and /usr/share/zoneinfo/{{ timezone | default("Etc/UTC") }} differ"

- name: Set Local Time
  command: mv /usr/share/zoneinfo/{{ timezone | default("Etc/UTC") }} /etc/localtime
  sudo: yes
  notify: Update Timezone
  when: localtime_diff.stdout != ""

Fix error when there actually IS a diff in times. Duh.
Fix error when there actually IS a diff in times. Duh.
