--- - 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" tags: [ 'packages', 'ntp' ] - block: - name: Install the ntpd server 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 zone {{ firewalld_default_zone }} firewalld: service=ntp zone={{ firewalld_default_zone }} permanent=True state=enabled immediate=True when: firewalld_enabled | bool when: ansible_distribution_file_variety == "RedHat" tags: [ 'packages', 'ntp' ]