🔴 FREE LIVE WEBINAR
How to Become a DevOps Engineer in 2027
From Zero to DevOps Champion!
November 21st, 2026
9:30 AM CST
Live DevSecOps CI/CD Demo
Career Roadmap • Live Q&A
REGISTER FOR FREE →
100% FREE • Live on Zoom
🎁 FREE CAREER GUIDE
2027 AI-Enabled DevSecOps Career Roadmap
Your Career Journey Starts Here!
📘
9-Stage Learning Roadmap
15-Week Study Plan
8-Page PDF + 12 Interview Q&As
GET FREE ROADMAP →
100% FREE • Delivered to Your Inbox
🚀 NEW WEEKEND BATCH
AI-Enabled DevSecOps & Cloud Engineering Bootcamp
Starts December 5th, 2026
Sat: 9:30 AM – 11:30 AM CST
Sun: 10:30 AM – 12:30 PM CST

15 Weeks • 70+ Labs • Live Training
REGISTER FOR BOOTCAMP → Explore Bootcamp →
Enrollment Open!
3,500+ Students Trained
25+ Years of IT Experience
70+ Hands-On Labs
🔴 Free Webinar Register Free
🎁 Free Roadmap Get Roadmap
🚀 Weekend Batch Enroll Now →

Friday, January 11, 2019

Ansible Playbook to install Java 8 on Ubuntu - How to install Java 8 using Ansible Playbook



Find below Ansible playbook to install Java 8 on Ubuntu

Step 1: Create the playbook first with name. for e.g, installJava.xml

---
- hosts: Java_Group

  tasks:
  - name: Update APT package manager repositories cache
    become: true
    apt:
      update_cache: yes

  - name: Install OpenJDK Java
    become: yes
    apt:
      name: "{{ item }}"
      state: present
    with_items:
     openjdk-8-jdk

2. sudo vi /etc/ansible/hosts

make sure you add below entry with target node IP changed (in red color).

[Java_Group] 
xx.xx.xx.xx ansible_ssh_user=ubuntu ansible_ssh_private_key_file=~/.ssh/id_rsa  ansible_python_interpreter=/usr/bin/python3

3. sudo ansible-playbook installJava.xml

now after successfully executing, enter below command in target node to make sure Java is installed:
java -version

No comments:

Post a Comment