---

- block:
  - name: install openjdk PPA
    apt_repository:
      repo: ppa:openjdk-r/ppa
      state: present

  - name: install java8
    apt:
      name: openjdk-8-jre-headless
      update_cache: yes
      cache_valid_time: 3600

  become: yes
  when: (java_version == 8)

- name: install java
  apt:
    name: openjdk-7-jre-headless
    update_cache: yes
    cache_valid_time: 3600
  become: yes
  when: (java_version == 7)



