As we transformed the common playbook into the common role, we can do the same for the webserver role.
In roles, we need to have the webserver folder with the tasks subfolder inside it. In this folder, we have to put the main.yaml file containing the tasks copied from the playbooks. The following is the code snippet; the full code is available on GitHub:
--- - name: Ensure the HTTPd package is installed yum: name: httpd state: present become: True - name: Ensure the HTTPd service is enabled and running service: name: httpd state: started enabled: True become: True - name: Ensure HTTP can pass the firewall firewalld: service: http state: enabled permanent: True immediate: True become: True
...
In this role, we have used multiple tasks that will need additional resources to work properly...