summaryrefslogtreecommitdiffstats
path: root/tasks/main.yml
blob: e88b109ee26e08392be74e61f860351acb1cbb73 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
---
- 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

- include: clock-rhel-6.yml
  when: ansible_os_family == 'RedHat' and ansible_distribution_version.split('.')[0] == '6'

- name: Set timezone
  timezone:
    name: "{{ ntp_timezone }}"

- name: Ensure NTP is running and enabled as configured.
  service:
    name: "{{ ntp_daemon }}"
    state: started
    enabled: yes
  when: ntp_enabled

- name: Ensure NTP is stopped and disabled as configured.
  service:
    name: "{{ ntp_daemon }}"
    state: stopped
    enabled: no
  when: not ntp_enabled

- name: Generate ntp.conf file
  template:
    src: ntp.conf.j2
    dest: /etc/ntp.conf
  notify: restart ntp
  when: ntp_manage_config