From 13f156c21d2885a0c5d0420fb87db82a676f067e Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Sun, 8 Oct 2017 16:51:54 -0500 Subject: [PATCH] split out TZ to 2-common --- roles/2-common/tasks/main.yml | 4 ---- roles/2-common/tasks/tz.yml | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 roles/2-common/tasks/tz.yml diff --git a/roles/2-common/tasks/main.yml b/roles/2-common/tasks/main.yml index 8b8df2f2e..638457f5f 100644 --- a/roles/2-common/tasks/main.yml +++ b/roles/2-common/tasks/main.yml @@ -32,10 +32,6 @@ - sysctl: name=net.ipv6.conf.default.disable_ipv6 value=1 state=present - sysctl: name=net.ipv6.conf.lo.disable_ipv6 value=1 state=present -- name: Set default Time Zone - shell: ln -sf /usr/share/zoneinfo/{{ iiab_TZ }} /etc/localtime - when: iiab_TZ is defined and iiab_TZ != "" - - name: Install custom profile file template: dest=/etc/profile.d/zzz_iiab.sh src=zzz_iiab.sh diff --git a/roles/2-common/tasks/tz.yml b/roles/2-common/tasks/tz.yml new file mode 100644 index 000000000..7857783e9 --- /dev/null +++ b/roles/2-common/tasks/tz.yml @@ -0,0 +1,20 @@ +- name: Check if the TZ is not already set - Can Fail + shell: readlink /etc/localtime | awk -F "zoneinfo/" '{print $2}' + register: TZ_set + ignore_errors: True + +- name: Set to UTC if the TZ is not set already set + set_fact: local_tz='UTC' iiab_TZ='UTC' + when: TZ_set.stdout == "" + +- name: Set default Timezone - Debian + shell: timedatectl set-timezone {{ iiab_TZ }} + when: is_debuntu and iiab_TZ is defined and iiab_TZ != "" and iiab_TZ != "TZ_set.stdout" + +- name: Set default Timezone - Redhat + shell: ln -sf /usr/share/zoneinfo/{{ iiab_TZ }} /etc/localtime + when: is_redhat and iiab_TZ is defined and iiab_TZ != "" and iiab_TZ != "TZ_set.stdout" + +- name: override ansible on timezone + set_fact: local_tz=TZ_set.stdout + when: TZ_set.stdout != ""