简体   繁体   中英

How to Install Java 8 Using Ansible Without PPA

I normally would install Java 8 with Ansible with the following code:

---
- name: Install add-apt-repostory
  become: yes
  apt: name=software-properties-common state=latest

- name: Add Oracle Java Repository
  become: yes
  apt_repository: repo='ppa:webupd8team/java'

- name: Accept Java 8 License
  become: yes
  debconf: name='oracle-java8-installer' question='shared/accepted-oracle-license-v1-1' value='true' vtype='select'

- name: Install Oracle Java 8
  become: yes
  apt: name={{item}} state=latest
  with_items:
    - oracle-java8-installer
    - ca-certificates
    - oracle-java8-set-default

Ref. the following stacked overflow question for original author.

How to install Oracle Java 8 using Ansible

However, since the Oracle JDK License has changed for releases on April 16, 2019. This PPA has been discontinued and my ansible code now returns the following error when attempting to install Java 8...

Package oracle-java8-installer is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source

E: Package 'oracle-java8-installer' has no installation candidate

Does anyone know how to automate the installation of Java 8 with Ansible now that the PPA has been discontinued and the Oracle Licences have changed?

In my case, I sign up for oracle account then download the .rpm/.tar.gz package directly from Oracle into one of my PC. I transfer the files to an ansible control server and use ansible playbook to distribute the files to other remote servers using copy module. Finally I write the ansible role to extract and install them locally using the following methods.

CentOS: You can easily use yum to install the rpm package.

Ubuntu: Follow these steps. https://www.vultr.com/docs/how-to-manually-install-java-8-on-ubuntu-16-04

It's not quite a good way since you need to transfer the installer to each server. I too still looking for a way to use script to download from the oracle website directly, but there is no way to do without sign on authentication.

You havr to download JDK (Java Devolpment Kit) and install. There is a file of name readme or something like this in text format. Then copy the text and paste. This type of info you can find easily on internet.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM