Ansible Roles
- Ansible Roles help in creating re-usable ansible assets.
- Ansible has huge collection of community roles developed and hosted in Ansible Galaxy Refer Here
- We can create our own custom ansible roles.
using existing Ansible role from Ansible Galaxy
- Lets use a role to install mysql Refer Here
- Refer Here for the usage of role to install mysql
- Lets try to syntax check the playbook

- The above error indicates that the role is not downloaded into the ansible control node from ansible galaxy
- Lets download the role using command
ansible-galaxy install geerlingguy.mysql - To summarize the steps are
- Create a playbook with roles
“`
</ul>
<hr />
<ul>
<li>name: test
roles:<ul>
<li>role: <name of role>
become: <yes|no>
“` - Create a playbook with roles
ansible-galaxy install <role> if it is from ansible galaxy or ensure the role is present in
current_dir/roles/<role-name>~/.ansible/roles/<role-name>- /etc/ansible/roles
- Install mongo db from ansible galaxy role
- Install docker from ansible galaxy role
- Go through the tomcat playbook as we will be converting that into role in next session.
