Skip to content
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](https://i1.wp.com/directdevops.blog/wp-content/uploads/2020/12/ansible53.png?w=800&ssl=1)
- 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](https://i2.wp.com/directdevops.blog/wp-content/uploads/2020/12/ansible54.png?w=800&ssl=1)
- 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
- 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