DevOps Classroomnotes 04/Aug/2022

Lets Use Ansible to deploy a Java application on Tomcat server (Contd…)

  • Manual Steps
sudo apt update
sudo apt install openjdk-8-jdk -y
sudo apt install tomcat9 -y
wget https://referenceapplicationskhaja.s3.us-west-2.amazonaws.com/gameoflife.war
sudo cp gameoflife.war /var/lib/tomcat9/webapps/
sudo systemctl restart tomcat9.service
  • The playbook so far
---
- name: deploy game of life
  become: yes
  hosts: all
  tasks:
    - name: update ubuntu packages
      ansible.builtin.apt:
        name: openjdk-8-jdk
        update_cache: yes
        state: present
  • The modules used to acheive the tomcat9 installation and game of life configuration:
  • Refer Here for the changes done.
  • Syntax check:
    Preview
  • Run the playbook
    Preview
  • Issue: When we run this playbook the java 11 is getting installed and gameof life is not working
    Preview
    Preview
  • Exercise -1: The issue observed in the class is due to ubuntu 22.04. Can you try executing the playbook on ubuntu 20.04
  • Try writing the ansible playbook for the following manual steps
$ sudo apt update
$ sudo apt install apache2 -y

# echo '<h1> Hello </h1>' > /var/www/html/info.html

=> http://<public-ip> 
=> http://<public-ip>/info.html

Leave a Reply

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

About continuous learner

devops & cloud enthusiastic learner