Skip to content

Instantly share code, notes, and snippets.

@bengosney
Created April 8, 2016 10:27
Show Gist options
  • Save bengosney/06b611c051c0f3e6d8837c9adbd553b9 to your computer and use it in GitHub Desktop.
Save bengosney/06b611c051c0f3e6d8837c9adbd553b9 to your computer and use it in GitHub Desktop.
Ansible timezone for CentOS
---
- name: Check current timezone
shell: "timedatectl | gawk -F'[: ]+' ' $2 ~ /Timezone/ {print $3}'"
register: current_zone
changed_when: False
- name: Set UTC timezone
file: src=/usr/share/zoneinfo/{{ timezone }} dest=/etc/localtime state=link force=yes
when: current_zone.stdout != '{{ timezone }}'
@bengosney
Copy link
Author

Updated for CentOS7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment