DevOps Classroomnotes 10/Jan/2023

Ansible Templates

  • Ansible uses jinja2 for templating Refer Here
  • In ansible to use the variables we use expression {{ variable_name }} which is derived from templating language jinja2
  • jinja2 also has wide filters
  • We can use jinja2 in files so that the content can be dynamic
  • we have created a sample template with simple text. Refer Here for the chagnes
    Preview
  • Refer Here for the changes in tomcat where we have used template rather than static file for users.xml
  • Refer Here for the changes done to remove duplicate service file
  • Tomcat was not running due to permission issues, so ensured permissions are checked every time Refer Here for the changes
  • Refer Here for the optional update added for ubuntu instance
  • Make changes in the tomcat playbook to use find /opt/tomcat/latest/bin' -name '*.sh' and use register variable and loop to apply execute permissions to all the shell files
  • For finding files use ansible.builtin.find module, use register variable and figure out a module to change the file permissions.

Leave a Reply

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

About continuous learner

devops & cloud enthusiastic learner