--- - block: - name: Install the ntp server apt: pkg=ntp state=present cache_valid_time=3600 - name: Install the ntp configuration. template: src=ntp.conf.j2 dest=/etc/ntp.conf owner=root group=root mode=0644 notify: Restart the ntp server - name: Ensure that the ntp server is running service: name=ntp state=started enabled=yes when: ntp_service_enabled | bool - name: Ensure that the ntp server is stopped and disabled service: name=ntp state=stopped enabled=no when: not ntp_service_enabled | bool when: - ansible_distribution_file_variety == "Debian" - ntp_service_install tags: [ 'packages', 'ntp' ] - block: - name: Install the ntpd server on CentOS <= 7 yum: pkg=ntp state=present - name: 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: Ensure that the ntpd server is running service: name=ntpd state=started enabled=yes when: ntp_service_enabled | bool - name: Ensure that the ntpd server is stopped and disabled service: name=ntpd state=stopped enabled=no when: not ntp_service_enabled | bool - name: 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 | bool tags: [ 'packages', 'ntp', 'firewall', 'iptables_rules' ] when: - ansible_distribution_file_variety == "RedHat" - ansible_distribution_major_version is version_compare('7', '<=') - ntp_service_install tags: [ 'packages', 'ntp' ] - block: - name: Install the ntpd server on CentOS >= 8 ansible.builtin.dnf: pkg: chrony state: present when: - ansible_distribution_file_variety == "RedHat" - ansible_distribution_major_version is version_compare('8', '>=') - ntp_service_install tags: [ 'packages', 'ntp' ]