DevOps Classroomnotes 05/Jan/2023

Possible fixes

  • When we execute ansible playbook on the node where everything is installed, changes shouldn’t happen. But as of now there are changes during every execution done by ansible
  • Context xml with same contents is created as two files and two times the copy is handled in two tasks
  • Ansible playbook which we have written works only for ubuntu, we need to extend this to work for other linux distributions.
  • If we need to make this playbook work for future versions of tomcat it will not as we have hardcoded 10.1.4
  • If we want extend this playbook to install any version of java

Variables in Ansible

  • Refer Here for the official docs
  • Lets create a simple playbook
---
- name: checking variable demo
  vars:
    name: qt
  hosts: all
  tasks:
    - name: print variable value
      debug:
        var: name
    - name: print something else
      debug:
        msg: "Hello, {{ name }}"


Preview
* Lets introduce the variables for tomcat playbook
* Refer Here for the changes done to include default variables. Refer Here for the changes done to fix the variable usage issue.

Lets try to make this playbook work with centos 7

  • Problem 1: Package managers might be different
    • Ansible has a module called package Refer Here
    • If the package name is same
---
- name: install utilty softwares
  become: yes
  hosts: all
  vars:
    apache_package: httpd
  tasks:
    - name: install git
      ansible.builtin.package:
        name: git
        state: present

Leave a Reply

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

About continuous learner

devops & cloud enthusiastic learner