]> git.apps.os.sepia.ceph.com Git - ceph-cm-ansible.git/commitdiff
Use separate codepaths for CentOS 6 vs. 7
authorZack Cerza <zack@redhat.com>
Wed, 20 Jan 2016 19:35:23 +0000 (12:35 -0700)
committerZack Cerza <zack@redhat.com>
Wed, 20 Jan 2016 19:35:23 +0000 (12:35 -0700)
Signed-off-by: Zack Cerza <zack@redhat.com>
roles/common/tasks/yum_systems.yml

index 931dd816bc68049f449b4ec0dba60869c682e12f..a7cdb23d71b14a253c24eca44ece25353a4a5d10 100644 (file)
@@ -1,19 +1,35 @@
 ---
-- name: Get the current timezone
+- name: Get the current timezone (RHEL/CentOS 6)
   shell: cut -d'"' -f2 /etc/sysconfig/clock
+  when: ansible_distribution_major_version == "6"
   register: current_tz
   changed_when: false
   tags:
     - timezone
 
-- name: Set the timezone
+- name: Get the current timezone (RHEL/CentOS 7)
+  shell: 'timedatectl | grep Timezone | sed -e "s/.*: \(.*\) (.*/\1/"'
+  when: ansible_distribution_major_version == "7"
+  register: current_tz
+  changed_when: false
+  tags:
+    - timezone
+
+- name: Set the timezone (RHEL/CentOS 6)
   file:
     src: /usr/share/zoneinfo/{{ timezone }}
     dest: /etc/localtime
     state: link
     force: yes
   # Default is used below to avoid breaking check mode
-  when: current_tz.stdout|default("") != timezone
+  when: ansible_distribution_major_version == "6" and current_tz.stdout|default("") != timezone
+  tags:
+    - timezone
+
+- name: Set the timezone (RHEL/CentOS 7)
+  command: timedatectl set-timezone {{ timezone }}
+  # Default is used below to avoid breaking check mode
+  when: ansible_distribution_major_version == "7" and current_tz.stdout|default("") != timezone
   tags:
     - timezone