In today's devops ecosystem, where "infrastructure is code", how do we test our infrastructure?
Ansible gives us one way to do this. When we install or update a service, run a service-specific command to make doubly sure that things are working as expected. If something's not quite right, Ansible will abort and we can figure out what went kablooey.
Save the following into "ntp.yml" and run with ansible-playbook -vvi myhost ntp.yml
Thanks to phillipuniverse !
# ntp.yml -- install NTP time sync daemon
# Adapted from https://gist.github.com/phillipuniverse/7721288#file-ntp_playbook-yml
# USAGE: ansible-playbook -vvi myhost ntp.yml
- hosts: all
- name: Install NTP
apt: package=ntp state=present update_cache=yes
- name: Make sure NTP is started up
service: name=ntp state=started enabled=yes
- name: verify NTP synchronized
command: timedatectl status
failed_when: "'synchronized: yes' not in ntp_result.stdout"
- name: restart ntp
service: name=ntp state=restarted