DevOps Classroom notes 14/Oct/2023

Activity 5: Install tomcat 10 server contd

  • Refer Here for manual steps
  • Refer Here for the changes done to configure manager and host manager app

Tags in ansible

  • Refer Here for tags
  • Lets add the tags to the tomcat playbook Refer Here for the changes done to add tags
  • The purpose of tags is run specific tasks or skip specific tasks
# runs only tasks with tag java
ansible-playbook -i hosts -t java tomcat.yaml
# run every thing but skips tag java
ansible-playbook -i hosts --skip-tags java tomcat.yaml

Re-usablity in Ansible

  • Using Ansible we can reuse the playbooks in 3 ways
    • import or include playbooks
    • roles
    • collections

Import or include playbooks

  • Refer Here for two simple playbooks first and second which print message
    Preview
  • Now we want to execute both first and second
  • import playbook Refer Here
  • Refer Here for changes
    Preview
  • the above approach brings reusability but the hosts and other factors are set in the individual playbooks
  • Refer Here for an approach where we have used import tasks
  • We can acheive the same by using include tasks Refer Here
  • Difference between include_ and import_ in ansible
    • include is dynamic i.e. we have flexibility fo using include tasks conditionally
    • import is static i.e. we need to execute this unconditionally

Ansible Roles

Ansible Collections

Exercise

  • Try this role and check if we can install mysql

Leave a Reply

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

About continuous learner

devops & cloud enthusiastic learner