Ansible timezone issue

It appears like there is a bug with setting the timezone with ansible. Maybe it will be fixed soon but a workaround like below worked for me.

Timezone module cannot set timezone in not systemd based system #19745

Should work like this:

   - name: set timezone to New_York
      name: America/New_York

Workaround like this:

   - timezone: America/New_York

   - name: Check current timezone
     shell: awk -F\" '{ print $2}' /etc/sysconfig/clock
     register: current_zone
     changed_when: False

   - name: Set EST timezone
     file: src=/usr/share/zoneinfo/{{ timezone }}  dest=/etc/localtime state=link force=yes
     when: current_zone.stdout != '{{ timezone }}'


Bio Info for Riaan