---

- name: install jenkins utilities
  apt:
    name:
      - bc
      - debootstrap
      - fakeroot
      - htop
      - proot
      - python3-setuptools
      - qemu-system-arm
      - qemu-user-static
      - virt-manager
    cache_valid_time: 3600
    update_cache: yes
    install_recommends: no
  when: install_jenkins_utilities

- name: stop checking release validity for old stable
  copy:
    content: 'Acquire::Check-Valid-Until "false";'
    dest: '/etc/apt/apt.conf.d/90-stop-check-release-validity'
  when: ansible_distribution == 'Debian' and ansible_distribution_release == 'jessie'

- name: enable backports for jessie
  apt_repository:
    repo: 'deb http://archive.debian.org/debian jessie-backports main'
    filename: 'backports'
    update_cache: yes
  when: ansible_distribution == 'Debian' and ansible_distribution_release == 'jessie'

- name: install java for jessie
  apt:
    name: openjdk-8-jre-headless
    cache_valid_time: 3600
    update_cache: yes
    install_recommends: no
    default_release: jessie-backports
  when: ansible_distribution == 'Debian' and ansible_distribution_release == 'jessie'

- name: install java for stretch
  apt:
    name:
      - openjdk-8-jre-headless
    cache_valid_time: 3600
    update_cache: yes
    install_recommends: no
  when: ansible_distribution == 'Debian' and ansible_distribution_version == '9'

- name: install java for buster and later
  apt:
    name:
      - default-jre-headless
    cache_valid_time: 3600
    update_cache: yes
    install_recommends: no
  when: ansible_distribution == 'Debian' and ansible_distribution_version|int >= 10
