DevOps Classroomnotes 23/Jan/2023

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 />
      <li>name: test
      <li>role: <name of role>
      become: <yes|no>

  • Ensure role is downloaded 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
  • Now syntax check the execution of ansible playbook
  • run the playbook which will call role and role does the execution which leads to a desired state.
  • Ansible postgres installation Refer Here
  • Exercises:
    • 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.
  • Leave a Reply

    This site uses Akismet to reduce spam. Learn how your comment data is processed.

    About continuous learner

    devops & cloud enthusiastic learner