|
8 | 8 | - wal_g_auto_conf | default(true) | bool # to be able to disable auto backup settings |
9 | 9 | tags: wal-g, wal_g, wal_g_conf |
10 | 10 |
|
| 11 | +# Pre-check |
11 | 12 | - name: Check if WAL-G is already installed |
12 | 13 | ansible.builtin.shell: | |
13 | 14 | set -o pipefail; |
14 | | - "{{ wal_g_path }}" --version | awk {'print $3'} | tr -d 'v' |
| 15 | + "{{ wal_g_path.split(' ')[0] }}" --version | awk {'print $3'} | tr -d 'v' |
15 | 16 | args: |
16 | 17 | executable: /bin/bash |
17 | 18 | changed_when: false |
|
29 | 30 | - wal_g_installed_version.stdout == wal_g_version |
30 | 31 | tags: wal-g, wal_g, wal_g_install |
31 | 32 |
|
32 | | -# Build WAL-G from source code for other Linux distributions |
| 33 | +# Install WAL-G from a precompiled binary |
| 34 | +# (if 'wal_g_installation_method' is 'binary') |
| 35 | +# Note: excluding RHEL 8 as GLIBC version 2.29 or higher is required. |
| 36 | +- block: |
| 37 | + - name: "Download WAL-G v{{ wal_g_version | replace('v', '') }} binary" |
| 38 | + ansible.builtin.get_url: |
| 39 | + url: "{{ wal_g_repo }}/{{ wal_g_archive }}" |
| 40 | + dest: /tmp/ |
| 41 | + timeout: 60 |
| 42 | + validate_certs: false |
| 43 | + vars: |
| 44 | + wal_g_repo: "https://github.com/wal-g/wal-g/releases/download/v{{ wal_g_version | replace('v', '') }}" |
| 45 | + wal_g_archive: "wal-g-pg-ubuntu-20.04-amd64.tar.gz" |
| 46 | + environment: "{{ proxy_env | default({}) }}" |
| 47 | + |
| 48 | + # Note: We are using a precompiled binary on Ubuntu 20.04, |
| 49 | + # but since Go binaries are cross-platform, it works well on other distributions as well. |
| 50 | + |
| 51 | + - name: Extract WAL-G into /tmp |
| 52 | + ansible.builtin.unarchive: |
| 53 | + src: "/tmp/wal-g-pg-ubuntu-20.04-amd64.tar.gz" |
| 54 | + dest: /tmp/ |
| 55 | + extra_opts: |
| 56 | + - --no-same-owner |
| 57 | + remote_src: true |
| 58 | + |
| 59 | + - name: Copy WAL-G binary file to "{{ wal_g_path.split(' ')[0] }}" |
| 60 | + ansible.builtin.copy: |
| 61 | + src: "/tmp/wal-g-pg-ubuntu-20.04-amd64" |
| 62 | + dest: "{{ wal_g_path.split(' ')[0] }}" |
| 63 | + mode: u+x,g+x,o+x |
| 64 | + remote_src: true |
| 65 | + when: |
| 66 | + - installation_method == "repo" |
| 67 | + - wal_g_installation_method == "binary" |
| 68 | + - wal_g_version is version('1.0', '>=') |
| 69 | + - (wal_g_installed_version.stderr is search("command not found") or wal_g_installed_version.stdout != wal_g_version) |
| 70 | + - not (ansible_os_family == "RedHat" and ansible_distribution_major_version == '8') |
| 71 | + tags: wal-g, wal_g, wal_g_install |
| 72 | + |
| 73 | +# Install WAL-G from the source code |
| 74 | +# (if 'wal_g_installation_method' is 'src') |
33 | 75 | - block: |
34 | 76 | - name: Install lib dependencies to build WAL-G |
35 | 77 | ansible.builtin.package: |
|
103 | 145 | when: go_installed_version.stderr is search("command not found") or |
104 | 146 | go_installed_version.stdout is version(wal_g_latest_version.stdout, '<') |
105 | 147 |
|
106 | | - - name: "Download WAL-G v{{ wal_g_version }} source code" |
| 148 | + - name: "Download WAL-G v{{ wal_g_version | replace('v', '') }} source code" |
107 | 149 | ansible.builtin.git: |
108 | 150 | repo: https://github.com/wal-g/wal-g.git |
109 | | - version: v{{ wal_g_version }} |
| 151 | + version: v{{ wal_g_version | replace('v', '') }} |
110 | 152 | dest: /tmp/wal-g |
| 153 | + force: true |
111 | 154 |
|
112 | 155 | - name: Run go mod tidy to ensure dependencies are correct |
113 | 156 | ansible.builtin.command: go mod tidy |
|
145 | 188 | environment: "{{ proxy_env | default({}) }}" |
146 | 189 | when: |
147 | 190 | - installation_method == "repo" |
| 191 | + - (wal_g_installation_method == "src" or (ansible_os_family == "RedHat" and ansible_distribution_major_version == '8')) |
148 | 192 | - wal_g_version is version('1.0', '>=') |
149 | 193 | - (wal_g_installed_version.stderr is search("command not found") or wal_g_installed_version.stdout != wal_g_version) |
150 | 194 | tags: wal-g, wal_g, wal_g_install |
151 | 195 |
|
152 | 196 | # older versions of WAL-G (for compatibility) |
153 | 197 | - block: |
154 | | - - name: "Download WAL-G v{{ wal_g_version }} binary" |
| 198 | + - name: "Download WAL-G v{{ wal_g_version | replace('v', '') }} binary" |
155 | 199 | ansible.builtin.get_url: |
156 | | - url: "https://github.com/wal-g/wal-g/releases/download/v{{ wal_g_version }}/wal-g.linux-amd64.tar.gz" |
| 200 | + url: "https://github.com/wal-g/wal-g/releases/download/v{{ wal_g_version | replace('v', '') }}/wal-g.linux-amd64.tar.gz" |
157 | 201 | dest: /tmp/ |
158 | 202 | timeout: 60 |
159 | 203 | validate_certs: false |
|
167 | 211 | - --no-same-owner |
168 | 212 | remote_src: true |
169 | 213 |
|
170 | | - - name: Copy WAL-G binary file to "{{ wal_g_path }}" |
| 214 | + - name: Copy WAL-G binary file to "{{ wal_g_path.split(' ')[0] }}" |
171 | 215 | ansible.builtin.copy: |
172 | 216 | src: "/tmp/wal-g" |
173 | | - dest: "{{ wal_g_path }}" |
| 217 | + dest: "{{ wal_g_path.split(' ')[0] }}" |
174 | 218 | mode: u+x,g+x,o+x |
175 | 219 | remote_src: true |
176 | 220 | when: |
177 | 221 | - installation_method == "repo" |
| 222 | + - wal_g_installation_method == "binary" |
178 | 223 | - wal_g_version is version('0.2.19', '<=') |
179 | | - - (wal_g_installed_version.stderr is search("command not found") or |
180 | | - wal_g_installed_version.stdout != wal_g_version) |
| 224 | + - (wal_g_installed_version.stderr is search("command not found") or wal_g_installed_version.stdout != wal_g_version) |
181 | 225 | tags: wal-g, wal_g, wal_g_install |
182 | 226 |
|
183 | 227 | # installation_method == "file" |
|
191 | 235 | extra_opts: |
192 | 236 | - --no-same-owner |
193 | 237 |
|
194 | | - - name: Copy WAL-G binary file to "{{ wal_g_path }}" |
| 238 | + - name: Copy WAL-G binary file to "{{ wal_g_path.split(' ')[0] }}" |
195 | 239 | ansible.builtin.copy: |
196 | 240 | src: "/tmp/{{ wal_g_package_file.split('.tar.gz')[0] | basename }}" |
197 | | - dest: "{{ wal_g_path }}" |
| 241 | + dest: "{{ wal_g_path.split(' ')[0] }}" |
198 | 242 | mode: u+x,g+x,o+x |
199 | 243 | remote_src: true |
200 | 244 | when: |
|
214 | 258 | extra_opts: |
215 | 259 | - --no-same-owner |
216 | 260 |
|
217 | | - - name: Copy WAL-G binary file to "{{ wal_g_path }}" |
| 261 | + - name: Copy WAL-G binary file to "{{ wal_g_path.split(' ')[0] }}" |
218 | 262 | ansible.builtin.copy: |
219 | 263 | src: "/tmp/wal-g" |
220 | | - dest: "{{ wal_g_path }}" |
| 264 | + dest: "{{ wal_g_path.split(' ')[0] }}" |
221 | 265 | mode: u+x,g+x,o+x |
222 | 266 | remote_src: true |
223 | 267 | when: |
|
0 commit comments