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

How to create Ubuntu 22.0.4 Virtual Machine (VM) in Azure? | Create Ubuntu 22.0.4 VM in Azure | How to connect to Azure VM from your local machine

 How to Create Ubuntu 22.0.4 Virtual Machines(VM) in Azure portal? Creating Virtual Machine is easy and straight forward in Azure Cloud. Let...