diff --git a/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/ant/tasks/main.yml b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/ant/tasks/main.yml index 30322a1e69..4149ccf862 100644 --- a/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/ant/tasks/main.yml +++ b/ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/ant/tasks/main.yml @@ -4,9 +4,14 @@ ############## # Install Apache Ant from binaries on RHEL and Centos +- name: Set default Ant version if not provided + set_fact: + ant_version: "{{ ant_version | default('1.10.5') }}" + tags: + - ant - name: Check if Apache Ant is already installed in custom location /usr/local - shell: ls /usr/local/apache-ant-1.10.5 >/dev/null 2>&1 + shell: ls /usr/local/apache-ant-{{ ant_version }} >/dev/null 2>&1 failed_when: false register: ant_installed changed_when: false @@ -16,7 +21,7 @@ - name: Download Apache Ant binaries get_url: - url: https://archive.apache.org/dist/ant/binaries/apache-ant-1.10.5-bin.zip + url: https://archive.apache.org/dist/ant/binaries/apache-ant-{{ ant_version }}-bin.zip dest: /tmp/ mode: 0440 timeout: 25 @@ -29,7 +34,9 @@ tags: ant - name: Download Apache Ant binaries (macOS) and (Solaris) - command: wget https://archive.apache.org/dist/ant/binaries/apache-ant-1.10.5-bin.zip -O /tmp/apache-ant-1.10.5-bin.zip + get_url: + url: https://archive.apache.org/dist/ant/binaries/apache-ant-{{ ant_version }}-bin.zip + dest: /tmp/apache-ant-{{ ant_version }}-bin.zip when: - ant_installed.rc != 0 - ansible_distribution == "MacOSX" or ansible_distribution == "Solaris" @@ -44,14 +51,16 @@ tags: ant - name: GPG Signature verification - script: ../Supporting_Scripts/package_signature_verification.sh -f /tmp/apache-ant-1.10.5-bin.zip -sl "https://archive.apache.org/dist/ant/binaries/apache-ant-1.10.5-bin.zip.asc" -k {{ key.apache_ant }} + script: ../Supporting_Scripts/package_signature_verification.sh -f /tmp/apache-ant-{{ ant_version }}-bin.zip -sl "https://archive.apache.org/dist/ant/binaries/apache-ant-{{ ant_version }}-bin.zip.asc" -k {{ key.apache_ant }} when: ant_installed.rc != 0 + environment: + PATH: "{{ ansible_env.PATH }}:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin" tags: ant - name: Extract ant become: true unarchive: - src: /tmp/apache-ant-1.10.5-bin.zip + src: /tmp/apache-ant-{{ ant_version }}-bin.zip dest: /usr/local copy: false when: @@ -69,7 +78,7 @@ - name: Create /usr/local/bin/ant symlink become: true file: - src: /usr/local/apache-ant-1.10.5/bin/ant + src: /usr/local/apache-ant-{{ ant_version }}/bin/ant dest: /usr/local/bin/ant state: link when: @@ -81,7 +90,7 @@ path: "{{ item }}" state: absent with_items: - - /tmp/apache-ant-1.10.5-bin.zip + - /tmp/apache-ant-{{ ant_version }}-bin.zip when: - ant_installed.rc != 0 failed_when: false