From 99451f84030d78f92b435881a542495016aafdc0 Mon Sep 17 00:00:00 2001 From: Jirayut Nimsaeng Date: Tue, 9 May 2017 15:40:39 +0700 Subject: Use timezone module for Ansible 2.2+ --- tasks/main.yml | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index c5a4d7f..491c04d 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -2,23 +2,33 @@ - name: Include OS-specific variables. include_vars: "{{ ansible_os_family }}.yml" -- name: Set the correct timezone. +- name: Configure timezone (For Ansible 2.2+) + timezone: + name: "{{ ntp_timezone }}" + when: ansible_version.full >= "02.02.00.00" + +- name: Set the correct timezone. (For Ansible prior 2.2) file: src: "/usr/share/zoneinfo/{{ ntp_timezone }}" dest: /etc/localtime state: link force: yes + when: ansible_version.full < "02.02.00.00" # Debian family OSes also have an /etc/timezone file. -- name: Set timezone in /etc/timezone file. +- name: Set timezone in /etc/timezone file. (For Ansible prior 2.2) template: src: timezone.j2 dest: /etc/timezone force: yes - when: ansible_os_family == 'Debian' + when: + - ansible_os_family == 'Debian' + - ansible_version.full < "02.02.00.00" - name: Install NTP. - package: name=ntp state=present + package: + name: ntp + state: present - name: Ensure NTP is running and enabled as configured. service: @@ -35,6 +45,8 @@ when: not ntp_enabled - name: Generate ntp.conf file - template: src=ntp.conf.j2 dest=/etc/ntp.conf + template: + src: ntp.conf.j2 + dest: /etc/ntp.conf notify: restart ntp when: ntp_manage_config -- cgit v1.2.3 From a24f36cf657799d793a5e364753c38f5ebd902c4 Mon Sep 17 00:00:00 2001 From: Jirayut Nimsaeng Date: Tue, 9 May 2017 20:26:42 +0700 Subject: Use timezone module and bump required minimum Ansible version to 2.2 --- meta/main.yml | 2 +- tasks/main.yml | 21 +-------------------- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/meta/main.yml b/meta/main.yml index 4cfa5a2..9e6dd69 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -6,7 +6,7 @@ galaxy_info: description: NTP installation and configuration for Linux. company: "Midwestern Mac, LLC" license: "license (BSD, MIT)" - min_ansible_version: 1.8 + min_ansible_version: 2.2 platforms: - name: EL versions: diff --git a/tasks/main.yml b/tasks/main.yml index 491c04d..8a14050 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -2,28 +2,9 @@ - name: Include OS-specific variables. include_vars: "{{ ansible_os_family }}.yml" -- name: Configure timezone (For Ansible 2.2+) +- name: Set timezone timezone: name: "{{ ntp_timezone }}" - when: ansible_version.full >= "02.02.00.00" - -- name: Set the correct timezone. (For Ansible prior 2.2) - file: - src: "/usr/share/zoneinfo/{{ ntp_timezone }}" - dest: /etc/localtime - state: link - force: yes - when: ansible_version.full < "02.02.00.00" - -# Debian family OSes also have an /etc/timezone file. -- name: Set timezone in /etc/timezone file. (For Ansible prior 2.2) - template: - src: timezone.j2 - dest: /etc/timezone - force: yes - when: - - ansible_os_family == 'Debian' - - ansible_version.full < "02.02.00.00" - name: Install NTP. package: -- cgit v1.2.3 From be80a0add73c8942405b5bc8ef68ca8d6de9fba5 Mon Sep 17 00:00:00 2001 From: Jirayut Nimsaeng Date: Tue, 9 May 2017 15:40:39 +0700 Subject: Use timezone module for Ansible 2.2+ --- tasks/main.yml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index afe3731..491c04d 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -2,20 +2,28 @@ - name: Include OS-specific variables. include_vars: "{{ ansible_os_family }}.yml" -- name: Set the correct timezone. +- name: Configure timezone (For Ansible 2.2+) + timezone: + name: "{{ ntp_timezone }}" + when: ansible_version.full >= "02.02.00.00" + +- name: Set the correct timezone. (For Ansible prior 2.2) file: src: "/usr/share/zoneinfo/{{ ntp_timezone }}" dest: /etc/localtime state: link force: yes + when: ansible_version.full < "02.02.00.00" # Debian family OSes also have an /etc/timezone file. -- name: Set timezone in /etc/timezone file. +- name: Set timezone in /etc/timezone file. (For Ansible prior 2.2) template: src: timezone.j2 dest: /etc/timezone force: yes - when: ansible_os_family == 'Debian' + when: + - ansible_os_family == 'Debian' + - ansible_version.full < "02.02.00.00" - name: Install NTP. package: -- cgit v1.2.3 From 1c16875b55c0c20f71e9c78b67cd38ce34022bd6 Mon Sep 17 00:00:00 2001 From: Jirayut Nimsaeng Date: Tue, 9 May 2017 20:26:42 +0700 Subject: Use timezone module and bump required minimum Ansible version to 2.2 --- meta/main.yml | 2 +- tasks/main.yml | 21 +-------------------- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/meta/main.yml b/meta/main.yml index 4cfa5a2..9e6dd69 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -6,7 +6,7 @@ galaxy_info: description: NTP installation and configuration for Linux. company: "Midwestern Mac, LLC" license: "license (BSD, MIT)" - min_ansible_version: 1.8 + min_ansible_version: 2.2 platforms: - name: EL versions: diff --git a/tasks/main.yml b/tasks/main.yml index 491c04d..8a14050 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -2,28 +2,9 @@ - name: Include OS-specific variables. include_vars: "{{ ansible_os_family }}.yml" -- name: Configure timezone (For Ansible 2.2+) +- name: Set timezone timezone: name: "{{ ntp_timezone }}" - when: ansible_version.full >= "02.02.00.00" - -- name: Set the correct timezone. (For Ansible prior 2.2) - file: - src: "/usr/share/zoneinfo/{{ ntp_timezone }}" - dest: /etc/localtime - state: link - force: yes - when: ansible_version.full < "02.02.00.00" - -# Debian family OSes also have an /etc/timezone file. -- name: Set timezone in /etc/timezone file. (For Ansible prior 2.2) - template: - src: timezone.j2 - dest: /etc/timezone - force: yes - when: - - ansible_os_family == 'Debian' - - ansible_version.full < "02.02.00.00" - name: Install NTP. package: -- cgit v1.2.3 From 86b8f5a1028386665c2c43bff2962b8ea476be78 Mon Sep 17 00:00:00 2001 From: Jeff Geerling Date: Sun, 11 Jun 2017 14:45:59 -0500 Subject: Fixes #33: Install tzdata alongside ntp so timezone data is present. --- .travis.yml | 2 +- tasks/main.yml | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6eb20a4..563f83c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,7 @@ env: - distro: ubuntu1404 - distro: ubuntu1204 - distro: fedora24 - # - distro: debian8 + - distro: debian8 script: # Download test shim. diff --git a/tasks/main.yml b/tasks/main.yml index 8a14050..a022447 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -2,15 +2,18 @@ - name: Include OS-specific variables. include_vars: "{{ ansible_os_family }}.yml" +- name: Ensure NTP-related packages are installed. + package: + name: "{{ item }}" + state: present + with_items: + - ntp + - tzdata + - name: Set timezone timezone: name: "{{ ntp_timezone }}" -- name: Install NTP. - package: - name: ntp - state: present - - name: Ensure NTP is running and enabled as configured. service: name: "{{ ntp_daemon }}" -- cgit v1.2.3