DevOps Classroom Series – 31/Dec/2020

Ansible jinja templates

  • Exercise: Now try Writing an ansible playbook for install tomcat8 on ubuntu and centos
  • As the part of above exercise we have written a playbook with inventory Refer Here
  • tomcat.service file is hard coded. In reality we would like to have configuration file configurable dynamically, So lets create a template Refer Here
  • Now lets identify the dynamic fields in this file and add jinja filters and use the template module Refer Here to copy the file
  • Refer Here for the changeset and also Refer Here

Lets look at jinja2 filters

  • Refer Here for jinja2 filter in ansible
  • using lower filter for changeset Refer Here Preview
  • Refer Here for all the built in filters
  • Refer Here for the changeset and also refer its parent commits
  • Ansible specific custom filters
  • Executing current job when the result of other job is success or changed Preview
  • Refer Here for the changeset

Problems to be resolved

  • As of now in the playbook tomcat_ubuntu we are including a variable file, now if we want to run this playbook for multiple environments like
    • Dev
    • QA
    • Prod
  • We might have different variables values, so how to effectively use the variable files
  • How to use the playbooks written by community?
  • How can make my playbook reusable?
  • Ansible Tower

Leave a Reply

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

About learningthoughtsadmin