Select Page

Installation of Oracle Java 8 is sometimes not as straight forward as it seems to be. So here is ansible playbook which covers all problems I found.

# install internal upcload repository
# based on
# run:
# ansible-playbook "yourplaybook.yaml" -i ./hosts

- name: install oracle java 8
  hosts: yourinstance
  gather_facts: yes

  - debug: msg="user={{ansible_user}}"

  - name: Install dependencies
    become: yes
    apt: name={{item}} state=latest
      - software-properties-common
      - dirmngr

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

  - name: Add Oracle Java Repository
    become: yes
      repo: deb trusty main
      state: present

  - name: Add an apt key by id from a keyserver
    become: yes
      id: EEA14886

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

  - name: update cache and ignore errors in case of problems
    become: yes
    apt: update_cache=yes
    ignore_errors: yes

  - name: purge java 8 installer - to avoid problems if installation is repeated
    become: yes
      name: oracle-java8-installer
      purge: yes
      state: absent
  - name: Install Oracle Java 8
    become: yes
    apt: name={{item}} state=latest 
      - ca-certificates
      - oracle-java8-installer
      - oracle-java8-set-default