|
1 | 1 | ---
|
2 |
| -############### |
3 |
| -# Ant-Contrib # |
4 |
| -############### |
| 2 | + |
5 | 3 |
|
6 | 4 | # ANT_HOME/lib is: /usr/local/apache-ant-*/lib
|
| 5 | +# Use the following variables: |
| 6 | +# antContribVersion: default('1.0b2') |
| 7 | +- name: set ant binary file name to variable |
| 8 | + set_fact: |
| 9 | + ant_binary_file_name: "{{ Ant_Download_URL.split('/')[-1].split('-bin')[0] }}" |
| 10 | + tags: ant-contrib |
7 | 11 |
|
8 | 12 | - name: Set ant-contrib version
|
9 |
| - set_fact: antContribVersion=1.0b2 |
| 13 | + set_fact: antContribVersion={{ antContribVersion | default('1.0b2') }} |
10 | 14 | tags: ant-contrib
|
11 | 15 |
|
12 | 16 | - name: Set ant_lib_dir variable for on {{ ansible_distribution }} {{ ansible_architecture }}
|
13 | 17 | set_fact:
|
14 |
| - ant_lib_dir: /usr/local/apache-ant-1.10.5/lib |
15 |
| - tags: ant-contrib |
16 |
| - |
17 |
| -- name: "Print ant_lib_dir variable" |
18 |
| - debug: var=ant_lib_dir |
| 18 | + ant_lib_dir: /usr/local/{{ ant_binary_file_name }}/lib |
19 | 19 | tags: ant-contrib
|
20 | 20 |
|
21 | 21 | - name: Check if ant-contrib is already installed
|
|
25 | 25 | tags: ant-contrib
|
26 | 26 |
|
27 | 27 | - name: Download ant-contrib
|
28 |
| - get_url: |
29 |
| - url: https://sourceforge.net/projects/ant-contrib/files/ant-contrib/ant-contrib-{{ antContribVersion }}/ant-contrib-{{ antContribVersion }}-bin.tar.gz |
30 |
| - dest: /tmp/ |
31 |
| - mode: 0440 |
32 |
| - timeout: 25 |
33 |
| - validate_certs: no |
34 |
| - checksum: sha256:c9b8b1ca18b13e293688cafbd8990c940ca49104dbeefc242e5c3f8de271abdf |
35 |
| - retries: 3 |
36 |
| - delay: 5 |
37 |
| - register: antContrib_download |
38 |
| - until: antContrib_download is not failed |
39 |
| - when: |
40 |
| - - not antcontrib_status.stat.exists |
41 |
| - - ansible_distribution != "MacOSX" |
42 |
| - - ansible_distribution != "Solaris" |
43 |
| - - not (ansible_distribution == "CentOS" and ansible_distribution_major_version == "6") |
44 |
| - tags: ant-contrib |
| 28 | + block: |
45 | 29 |
|
46 |
| -# Use wget instead of ansible's get_url for Centos 6 https://github.com/adoptium/infrastructure/issues/2486 |
| 30 | + - name: Download ant-contrib |
| 31 | + get_url: |
| 32 | + url: https://sourceforge.net/projects/ant-contrib/files/ant-contrib/ant-contrib-{{ antContribVersion }}/ant-contrib-{{ antContribVersion }}-bin.tar.gz |
| 33 | + dest: /tmp/ |
| 34 | + mode: 0440 |
| 35 | + timeout: 25 |
| 36 | + validate_certs: no |
| 37 | + checksum: sha256:c9b8b1ca18b13e293688cafbd8990c940ca49104dbeefc242e5c3f8de271abdf |
| 38 | + retries: 3 |
| 39 | + delay: 5 |
| 40 | + register: antContrib_download |
| 41 | + until: antContrib_download is not failed |
| 42 | + when: |
| 43 | + - ansible_distribution != "MacOSX" |
| 44 | + - ansible_distribution != "Solaris" |
| 45 | + - not (ansible_distribution == "CentOS" and ansible_distribution_major_version == "6") |
47 | 46 |
|
48 |
| -- name: Download ant-contrib (CentOS 6) |
49 |
| - command: wget https://sourceforge.net/projects/ant-contrib/files/ant-contrib/ant-contrib-{{ antContribVersion }}/ant-contrib-{{ antContribVersion }}-bin.tar.gz -O /tmp/ant-contrib-{{ antContribVersion }}-bin.tar.gz |
50 |
| - retries: 3 |
51 |
| - delay: 5 |
52 |
| - register: antContrib_download |
53 |
| - until: antContrib_download is not failed |
54 |
| - when: |
55 |
| - - not antcontrib_status.stat.exists |
56 |
| - - ansible_distribution == "CentOS" and ansible_distribution_major_version == "6" |
57 |
| - tags: ant-contrib |
| 47 | + # Use wget instead of ansible's get_url for Centos 6 https://github.com/adoptium/infrastructure/issues/2486 |
58 | 48 |
|
59 |
| -- name: Verify sha256 checksum of download (CentOS 6) |
60 |
| - stat: |
61 |
| - path: /tmp/ant-contrib-{{ antContribVersion }}-bin.tar.gz |
62 |
| - checksum_algorithm: sha256 |
63 |
| - get_checksum: yes |
64 |
| - register: antcontrib_checksum |
65 |
| - failed_when: antcontrib_checksum.stat.checksum != 'c9b8b1ca18b13e293688cafbd8990c940ca49104dbeefc242e5c3f8de271abdf' |
66 |
| - when: |
67 |
| - - not antcontrib_status.stat.exists |
68 |
| - - ansible_distribution == "CentOS" and ansible_distribution_major_version == "6" |
69 |
| - tags: ant-contrib |
| 49 | + - name: Download ant-contrib (CentOS 6) |
| 50 | + command: wget https://sourceforge.net/projects/ant-contrib/files/ant-contrib/ant-contrib-{{ antContribVersion }}/ant-contrib-{{ antContribVersion }}-bin.tar.gz -O /tmp/ant-contrib-{{ antContribVersion }}-bin.tar.gz |
| 51 | + retries: 3 |
| 52 | + delay: 5 |
| 53 | + register: antContrib_download |
| 54 | + until: antContrib_download is not failed |
| 55 | + when: |
| 56 | + - ansible_distribution == "CentOS" and ansible_distribution_major_version == "6" |
70 | 57 |
|
71 |
| -- name: Download ant-contrib (macOS) and (Solaris) |
72 |
| - command: wget https://sourceforge.net/projects/ant-contrib/files/ant-contrib/ant-contrib-{{ antContribVersion }}/ant-contrib-{{ antContribVersion }}-bin.tar.gz -O /tmp/ant-contrib-{{ antContribVersion }}-bin.tar.gz |
73 |
| - retries: 3 |
74 |
| - delay: 5 |
75 |
| - register: antContrib_download |
76 |
| - until: antContrib_download is not failed |
77 |
| - when: |
78 |
| - - not antcontrib_status.stat.exists |
79 |
| - - ansible_distribution == "MacOSX" or ansible_distribution == "Solaris" |
80 |
| - tags: ant-contrib |
| 58 | + - name: Verify sha256 checksum of download (CentOS 6) |
| 59 | + stat: |
| 60 | + path: /tmp/ant-contrib-{{ antContribVersion }}-bin.tar.gz |
| 61 | + checksum_algorithm: sha256 |
| 62 | + get_checksum: yes |
| 63 | + register: antcontrib_checksum |
| 64 | + failed_when: antcontrib_checksum.stat.checksum != 'c9b8b1ca18b13e293688cafbd8990c940ca49104dbeefc242e5c3f8de271abdf' |
| 65 | + when: |
| 66 | + - ansible_distribution == "CentOS" and ansible_distribution_major_version == "6" |
81 | 67 |
|
82 |
| -- name: Extract ant-contrib |
83 |
| - unarchive: |
84 |
| - src: /tmp/ant-contrib-{{ antContribVersion }}-bin.tar.gz |
85 |
| - dest: /tmp/ |
86 |
| - copy: False |
87 |
| - when: not antcontrib_status.stat.exists |
88 |
| - tags: ant-contrib |
| 68 | + - name: Download ant-contrib (macOS) and (Solaris) |
| 69 | + get_url: |
| 70 | + url: "https://sourceforge.net/projects/ant-contrib/files/ant-contrib/ant-contrib-{{ antContribVersion }}/ant-contrib-{{ antContribVersion }}-bin.tar.gz" |
| 71 | + dest: "/tmp" |
| 72 | + retries: 3 |
| 73 | + delay: 5 |
| 74 | + register: antContrib_download |
| 75 | + until: antContrib_download is not failed |
| 76 | + when: |
| 77 | + - ansible_distribution == "MacOSX" or ansible_distribution == "Solaris" |
89 | 78 |
|
90 |
| -- name: Move ant-contrib.jar to ant lib folder |
91 |
| - command: mv /tmp/ant-contrib/lib/ant-contrib.jar {{ ant_lib_dir }} |
92 |
| - when: not antcontrib_status.stat.exists |
93 |
| - tags: ant-contrib |
| 79 | + - name: Creates directory {{ ant_lib_dir }} |
| 80 | + file: |
| 81 | + path: "{{ ant_lib_dir }}" |
| 82 | + state: directory |
| 83 | + become: true |
| 84 | + |
| 85 | + - name: Extract ant-contrib |
| 86 | + unarchive: |
| 87 | + src: /tmp/ant-contrib-{{ antContribVersion }}-bin.tar.gz |
| 88 | + dest: /tmp |
| 89 | + copy: False |
| 90 | + when: |
| 91 | + - ansible_distribution != "MacOSX" |
| 92 | + |
| 93 | + - name: Extract ant-contrib tar -xf /tmp/ant-contrib-{{ antContribVersion }}-bin.tar.gz -C /tmp |
| 94 | + command: tar -xf /tmp/ant-contrib-{{ antContribVersion }}-bin.tar.gz -C /tmp |
| 95 | + register: antcontrib_unpack |
| 96 | + become: true |
| 97 | + until: antcontrib_unpack is not failed |
| 98 | + when: |
| 99 | + - ansible_distribution == "MacOSX" |
94 | 100 |
|
95 |
| -- name: Remove downloaded packages for ant-contrib |
96 |
| - file: |
97 |
| - path: "{{ item }}" |
98 |
| - state: absent |
99 |
| - with_items: |
100 |
| - - /tmp/ant-contrib |
101 |
| - - /tmp/ant-contrib-{{ antContribVersion }}-bin.tar.gz |
102 |
| - failed_when: false |
| 101 | + - name: copy ant-contrib /tmp/ant-contrib/lib/ant-contrib.jar into /usr/local/{{ ant_binary_file_name }}/lib |
| 102 | + copy: |
| 103 | + src: /tmp/ant-contrib/lib/ant-contrib.jar |
| 104 | + dest: "/usr/local/{{ant_binary_file_name }}/lib/" |
| 105 | + remote_src: true |
| 106 | + become: true |
| 107 | + |
| 108 | + - name: Cleanup after ant-contrib installed |
| 109 | + file: |
| 110 | + path: "{{ item }}" |
| 111 | + state: absent |
| 112 | + with_items: |
| 113 | + - /tmp/ant-contrib/ |
| 114 | + - /tmp/ant-contrib-{{ antContribVersion }}-bin.tar.gz |
| 115 | + failed_when: false |
| 116 | + become: true |
| 117 | + |
103 | 118 | tags: ant-contrib
|
| 119 | + when: |
| 120 | + - not antcontrib_status.stat.exists |
0 commit comments