This article shows how to install and configure the NTP client using Ansible. I’ve cheated a little by using the “ntpdate” command rather than a service. But i find this more reliable.
The following is the yml file:
--- - hosts: all sudo: yes tasks: - name: Install ntpdate yum: name: ntpdate state: latest - copy: src: files/cron.ntpdate dest: /etc/cron.d/cron.ntpdate owner: root group: root mode: 0644
And the file “./files/cron.ntpdate” that will be used for the cron-job:
0,11 * * * * root /usr/sbin/ntpdate ntp.example.com
The above should solve your problems.