From 13f156c21d2885a0c5d0420fb87db82a676f067e Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Sun, 8 Oct 2017 16:51:54 -0500 Subject: [PATCH 1/3] 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 != "" From aafba9c52094809d6bf54f695217799000729cea Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Sun, 8 Oct 2017 16:55:57 -0500 Subject: [PATCH 2/3] check for TZ change post-install move tz.yml to 0-init --- roles/0-init/tasks/main.yml | 3 +-- roles/{2-common => 0-init}/tasks/tz.yml | 7 +++++-- 2 files changed, 6 insertions(+), 4 deletions(-) rename roles/{2-common => 0-init}/tasks/tz.yml (86%) diff --git a/roles/0-init/tasks/main.yml b/roles/0-init/tasks/main.yml index dd80cc686..8debb36a2 100644 --- a/roles/0-init/tasks/main.yml +++ b/roles/0-init/tasks/main.yml @@ -74,8 +74,7 @@ # Put all computed vars here so derive properly from any prior var file - name: If the TZ is not set in env, set it to UTC - set_fact: local_tz='UTC' - when: local_tz == "" + include_tasks: tz.yml - name: Set port 80 for Admin Console set_fact: diff --git a/roles/2-common/tasks/tz.yml b/roles/0-init/tasks/tz.yml similarity index 86% rename from roles/2-common/tasks/tz.yml rename to roles/0-init/tasks/tz.yml index 7857783e9..91745f002 100644 --- a/roles/2-common/tasks/tz.yml +++ b/roles/0-init/tasks/tz.yml @@ -4,7 +4,9 @@ ignore_errors: True - name: Set to UTC if the TZ is not set already set - set_fact: local_tz='UTC' iiab_TZ='UTC' + set_fact: + local_tz: 'UTC' + iiab_TZ: 'UTC' when: TZ_set.stdout == "" - name: Set default Timezone - Debian @@ -16,5 +18,6 @@ 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 + set_fact: + local_tz: '{{ TZ_set.stdout }}' when: TZ_set.stdout != "" From a311d988b407129b69c7d38c2bcb9321779e949d Mon Sep 17 00:00:00 2001 From: Jerry Vonau Date: Sat, 18 Nov 2017 22:09:31 -0600 Subject: [PATCH 3/3] tz.yml - discriptions and order --- roles/0-init/tasks/tz.yml | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/roles/0-init/tasks/tz.yml b/roles/0-init/tasks/tz.yml index 91745f002..d2e0f4991 100644 --- a/roles/0-init/tasks/tz.yml +++ b/roles/0-init/tasks/tz.yml @@ -1,23 +1,32 @@ -- name: Check if the TZ is not already set - Can Fail +- name: Check if the TZ is not already set via /etc/localtime - 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 +- name: Set local and iiab TZ to UTC if /etc/localtime is not 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 +- name: Override ansible on timezone if TZ set set_fact: local_tz: '{{ TZ_set.stdout }}' when: TZ_set.stdout != "" + +- name: Using iiab TZ for local TZ + set_fact: + local_tz: '{{ iiab_TZ }}' + when: iiab_TZ is defined and iiab_TZ != "" and iiab_TZ != "TZ_set.stdout" + +- name: Set default Timezone from iiab TZ - 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 from iiab TZ - Redhat + file: + path: /etc/localtime + src: /usr/share/zoneinfo/{{ iiab_TZ }} + force: yes + state: link + when: is_redhat and iiab_TZ is defined and iiab_TZ != "" and iiab_TZ != "TZ_set.stdout"