上QQ阅读APP看书,第一时间看更新
Ensuring that NTP is installed, configured, and running
To make sure NTP is present, we use the yum module:
- name: Ensure NTP is installed yum: name: ntp state: present become: True
Now that we know that NTP is installed, we should ensure that the server is using the timezone that we want. To do so, we will create a symbolic link in /etc/localtime that will point to the wanted zoneinfo file:
- name: Ensure the timezone is set to UTC file: src: /usr/share/zoneinfo/GMT dest: /etc/localtime state: link become: True
As you can see, we have used the file module, specifying that it needs to be a link (state: link).
To complete the NTP configuration, we need to start the ntpd service and ensure that it will run at every consequent boot:
- name: Ensure the NTP service is running and enabled service: name: ntpd state: started enabled: True become: True