Skip to content

Ansible timezone issue

wordpress meta

title: 'Ansible timezone issue'
date: '2017-01-26T13:16:52-06:00'
status: publish
permalink: /ansible-timezone-issue
author: admin
excerpt: ''
type: post
id: 1043
    - Ansible
tag: []
post_format: []

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 }}'