The last thing we need to do to complete this role is to create the handler for the Restart HTTPd notification. To do so, we will need to create a main.yaml file in roles/webserver/handlers with the following content:
--- - name: Restart HTTPd service: name: httpd state: restarted become: True
As you may have noticed, this is very similar to the handler we used in the playbook, if not for the file location and indentation.
The only thing that we still need to do to make our role applicable is to add the entry to the playbooks/groups/webserver.yaml file so that Ansible is informed that the servers in the web server group should apply the web server role as well as the common role. Our playbooks/groups/webserver.yaml file will need to be like the following:
--- - hosts: webserver user: ansible roles: - common - webserver
We could...