summaryrefslogtreecommitdiffstats
path: root/tasks/main.yml
diff options
context:
space:
mode:
authorJirayut Nimsaeng <wingth@gmail.com>2017-05-09 15:40:39 +0700
committerJirayut Nimsaeng <wingth@gmail.com>2017-05-09 15:40:39 +0700
commit99451f84030d78f92b435881a542495016aafdc0 (patch)
treebc388a44462b534b627ed79fcfbf01fbb9217a05 /tasks/main.yml
parentd7eba652db7cba3638400070dea90992ec92fdeb (diff)
downloadntp-99451f84030d78f92b435881a542495016aafdc0.tar.gz
ntp-99451f84030d78f92b435881a542495016aafdc0.tar.bz2
ntp-99451f84030d78f92b435881a542495016aafdc0.tar.xz
ntp-99451f84030d78f92b435881a542495016aafdc0.zip
Use timezone module for Ansible 2.2+
Diffstat (limited to 'tasks/main.yml')
-rw-r--r--tasks/main.yml22
1 files 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