KAMI911/ansible-role-java-open-jdk11

View on GitHub
tasks/download.yml

Summary

Maintainability
Test Coverage
---
# download and uncompress tasks file for ansible-role-java-open-jdk11

- name: check if Java is installed.
  stat: path='{{ java_folder }}/release'
  register: java_installed

- name: creating directory
  file:
    path: '{{ java_folder }}'
    state: directory
    mode: 0775
    owner: root
    group: root
  when: not java_installed.stat.exists or force_java_install

- name: is already downloaded locally
  become: false
  stat:
    path: '{{ java_download_filename }}'
  delegate_to: localhost
  register: java_is_local_download_file

- name: is already downloaded
  stat:
    path: '{{ java_archive }}'
  register: java_is_download_file

- block:
    - name: 'downloading Java 11 JDK file {{ java_download_filename }} to local machine'
      become: false
      get_url:
        url: '{{ java_download_url }}'
        validate_certs: false
        dest: './{{ java_download_filename }}'
        mode: 0644
      delegate_to: localhost
      run_once: true
      when: ( not java_is_local_download_file.stat.exists or java_installer_force_overwrite ) and java_installer_force_download and java_installer_local

    - name: copy java tar file
      copy:
        src: '{{ java_download_filename }}'
        dest: '{{ java_archive }}'
        mode: 0644
      when: ( not java_is_download_file.stat.exists or java_installer_force_overwrite ) and java_installer_local
  when: java_installer_local

- name: 'downloading Java 11 JDK file {{ java_download_filename }}'
  get_url:
    url: '{{ java_download_url }}'
    validate_certs: false
    dest: '{{ java_archive }}'
    mode: 0644
  when: ( not java_is_download_file.stat.exists or java_installer_force_overwrite ) and java_installer_force_download and not java_installer_local

- name: 'uncompressing {{ java_download_filename }} file'
  unarchive:
    src: '{{ java_archive }}'
    dest: '{{ java_usr_folder }}'
    owner: root
    group: root
    copy: false
  when: not java_installed.stat.exists or force_java_install

- name: remove downloaded file
  file:
    path: '{{ java_archive }}'
    state: absent
  when: not java_installer_keep