2016-08-26 23:06:02 +02:00

29 lines
853 B
YAML

---
# ansible/roles/ntp/tasks/main.yml
- name: Ensure ntpdate is not installed (and uninstall it if necessary)
apt: name=ntpdate state=absent
become: true
- name: Ensure the latest ntp is installed
apt: name=ntp state=latest update_cache=yes
become: true
- name: Retrieve facts about the file /etc/ntp.conf
stat: path=/etc/ntp.conf
register: ntp_conf_file
- debug: var=ntp_conf_file.stat.exists
- name: Fail when /etc/ntp.conf doesn't exist
fail: msg="The NTP config file /etc/ntp.conf doesn't exist'"
when: ntp_conf_file.stat.exists == False
# For now, we assume the default /etc/ntp.conf file is okay
- name: Ensure the ntp service is now started and should start on boot (enabled=yes)
service: name=ntp state=started enabled=yes
become: true
# All notified handlers are executed now (only once each, and only if notified)