---
- name: Java - Add repository
  command: add-apt-repository -y ppa:webupd8team/java
  become: true

- name: Java - Accept Java 7 License
  debconf: 
    name: 'oracle-java7-installer'
    question: 'shared/accepted-oracle-license-v1-1'
    value: 'true'
    vtype: 'select'
  become: true

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

- name: Java - Install packages
  apt:
    name={{ item }} state=present update_cache=yes
  become: true
  with_items:
    - oracle-java7-installer
    - oracle-java8-installer


---
- name: Java - Add repository
  command: add-apt-repository -y ppa:webupd8team/java
  become: true

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

- name: Java - Install packages
  apt:
    name={{ item }} state=present update_cache=yes
  become: true
  with_items:
    - oracle-java8-installer


Remove Java 7 which is no longer downloadable from Oracle
Remove Java 7 which is no longer downloadable from Oracle
