ansible-role-ntp/tasks/ntp-el.yml

41 lines
1.4 KiB
YAML

---
- name: ntp-el | Manage the NTP service in the EL distributions
when:
- ansible_distribution_major_version is version_compare('7', '<=')
- ntp_service_enabled
tags: [ 'packages', 'ntp' ]
block:
- name: ntp-el | Install the ntpd server on CentOS <= 7
yum: pkg=ntp state=present
- name: ntp-el | Install the ntp configuration.
template: src=ntp-centos.conf.j2 dest=/etc/ntp.conf owner=root group=root mode=0644
notify: Restart the ntpd server
- name: ntp-el | Ensure that the ntpd server is running
service: name=ntpd state=started enabled=yes
when: ntp_service_enabled
- name: ntp-el | Ensure that the ntpd package is absent when not required
ansible.builtin.yum:
pkg: ntp
state: present
when: not ntp_service_enabled
- name: ntp-el | Manage the ntp firewalld rules in the {{ firewalld_default_zone }} zone
firewalld: service=ntp zone={{ firewalld_default_zone }} permanent=True state={{ ntp_enable_default_firewalld_rule }} immediate=True
when: firewalld_enabled
tags: [ 'packages', 'ntp', 'firewall', 'iptables_rules' ]
- name: ntp-el | Manage the NTP service in the EL distributions
when:
- ansible_distribution_major_version is version_compare('8', '>=')
- ntp_service_enabled
tags: [ 'packages', 'ntp' ]
block:
- name: ntp-el |Install the Chrony server on CentOS >= 8
ansible.builtin.dnf:
pkg: chrony
state: present