Running the role

Now that we have our role written, we can add it to our playbook:

---- hosts: boxes  gather_facts: true  become: yes  become_method: sudo  vars_files:    - group_vars/common.yml  roles:    - roles/common    - roles/apache    - roles/mariadb

Again, we can rerun the playbook using:

$ ansible-playbook -i production site.yml

This will work through the common and Apache roles before moving on to the MariaDB equivalent. This playbook output starts just before the the MariaDB role begins:

TASK [roles/apache : set the selinux allowing httpd_t to be permissive] ***************************************************************************************************ok: [box]TASK [roles/apache : copy the test HTML page to the document root] ******************************************************************************************************** ...

Get Learn Ansible now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.