Command run: sudo ansible-playbook site.yml --connection=local
Distributor ID: Ubuntu Description: Ubuntu 18.04 LTS Release: 18.04 Codename: bionic ansible 2.5.5
I'm encountering this error only on my first run through after I change the following variable in the following file:
./group_vars/all
ntpserver: pool.ntp.org
TASK [common : Configure NTP file] **************************************************************************************************************
ERROR! The requested handler 'restart ntp' was not found in either the main handlers list nor in the listening handlers list
On my second run through, I'm having no issues:
TASK [common : Configure NTP file] **************************************************************************************************************
ok: [127.0.0.1] => {"changed": false, "checksum": "cc9e1a2d8777588fa4675e52f7ca7e352b23188a", "dest": "/etc/ntp.conf", "gid": 0, "group": "root", "mode": "0644", "owner": "root", "path": "/etc/ntp.conf", "size": 139, "state": "file", "uid": 0}
The folder and file structure I'm using is as follows:
https://github.com/ansible/ansible-examples/tree/master/lamp_simple_rhel7
./roles/common/handlers
- name: Restart NTP service: name=ntpd state=restarted`
./roles/common/tasks
---
- name: Install NTP
apt: name=ntp state=present
tags: ntp
- name: Configure NTP file
template: src=ntp.conf.j2 dest=/etc/ntp.conf
tags: ntp
notify: restart ntp
- name: Install common packages
apt: name={{ item }} state=present
with_items:
- fail2ban
- ranger
- name: Start the NTP service
service: name=ntp state=started enabled=yes
tags: ntp
- name: Upgrade all packages to the latest version
become: true
apt:
upgrade: yes
update_cache: yes
cache_valid_time: 86400 # one-day