ansible/roles/common/tasks/ntp.yml
2023-09-25 10:40:20 +02:00

52 lines
1.1 KiB
YAML

# 2023-09-25
# Tasks: ntp
---
- ansible.builtin.include_vars: ntp.yml
- name: Install NTP
ansible.builtin.package:
name: "{{ ntp_package_daemon }}"
state: present
when:
- ansible_facts['system'] == "Linux"
tags:
- apt
- packages
- ntp
- add
- name: Install tzdata
ansible.builtin.package:
name: "{{ ntp_package_tzdata }}"
state: present
when:
- ansible_facts['system'] == "Linux"
tags:
- apt
- packages
- tzdata
- add
- name: Populate service facts
service_facts:
- name: Disable systemd-timesyncd (if it's running but ntp is enabled)
ansible.builtin.service:
name: systemd-timesyncd.service
enabled: false
state: stopped
when:
- ansible_facts['system'] == "Linux"
- ntp_enabled | bool
- '"systemd-timesyncd.service" in services'
- services["systemd-timesyncd.service"]["status"] != "not-found"
- name: Process ntp template
ansible.builtin.template:
src: "{{ ntp_conf_template }}"
dest: "{{ ntp_conf_distribution }}"
mode: u=rw,g=r,o=r
when:
- ansible_facts['system'] == "Linux"