Skip to content

Commit

Permalink
unixPB: improves download and verify of ant binary
Browse files Browse the repository at this point in the history
by replacing `command: wget` with `get_url` module, it helps to support more systems. Also while running `GPG Signature verification` some systems (e.g old mac machines) have problem with wget while running `package_signature_verification.sh`. This change makes sure all systems will find wget in their `PATH`. Also makes `ant_version` a facts sat by default to `1.10.5` unless it is provided.

Sigend-off-by: [email protected]
  • Loading branch information
mahdipub committed Dec 4, 2024
1 parent d483066 commit 02c0534
Showing 1 changed file with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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"
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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
Expand Down

0 comments on commit 02c0534

Please sign in to comment.