{"id":1043,"date":"2017-01-26T13:16:52","date_gmt":"2017-01-26T19:16:52","guid":{"rendered":"http:\/\/blog.ls-al.com\/?p=1043"},"modified":"2017-01-26T13:18:37","modified_gmt":"2017-01-26T19:18:37","slug":"ansible-timezone-issue","status":"publish","type":"post","link":"https:\/\/blog.ls-al.com\/ansible-timezone-issue\/","title":{"rendered":"Ansible timezone issue"},"content":{"rendered":"

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.<\/p>\n

Issue:<\/strong>
\nTimezone module cannot set timezone in not systemd based system #19745
\nhttps:\/\/github.com\/ansible\/ansible\/issues\/19745<\/p>\n

Should work like this:<\/strong><\/p>\n

\r\n   - name: set timezone to New_York\r\n     timezone:\r\n      name: America\/New_York\r\n<\/pre>\n

Workaround like this:<\/strong><\/p>\n

\r\n  vars:\r\n   - timezone: America\/New_York\r\n\r\n\r\n   - name: Check current timezone\r\n     shell: awk -F\\" '{ print $2}' \/etc\/sysconfig\/clock\r\n     register: current_zone\r\n     changed_when: False\r\n\r\n   - name: Set EST timezone\r\n     file: src=\/usr\/share\/zoneinfo\/{{ timezone }}  dest=\/etc\/localtime state=link force=yes\r\n     when: current_zone.stdout != '{{ timezone }}'\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"

It appears like there is a bug with setting the timezone with ansible. Maybe it will be fixed soon but<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[74],"tags":[],"class_list":["post-1043","post","type-post","status-publish","format-standard","hentry","category-ansible"],"_links":{"self":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/posts\/1043","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/comments?post=1043"}],"version-history":[{"count":0,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/posts\/1043\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/media?parent=1043"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/categories?post=1043"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/tags?post=1043"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}