|
1 | 1 | - name: PostgREST - system user |
2 | | - user: name=postgrest |
| 2 | + ansible.builtin.user: |
| 3 | + name: 'postgrest' |
| 4 | + state: 'present' |
3 | 5 |
|
4 | 6 | - name: PostgREST - add Postgres PPA gpg key |
5 | | - apt_key: |
6 | | - url: https://www.postgresql.org/media/keys/ACCC4CF8.asc |
7 | | - state: present |
| 7 | + ansible.builtin.apt_key: |
| 8 | + url: 'https://www.postgresql.org/media/keys/ACCC4CF8.asc' |
| 9 | + state: 'present' |
8 | 10 |
|
9 | 11 | - name: PostgREST - add Postgres PPA main |
10 | | - apt_repository: |
| 12 | + ansible.builtin.apt_repository: |
| 13 | + filename: 'postgresql-pgdg' |
11 | 14 | repo: "deb http://apt.postgresql.org/pub/repos/apt/ noble-pgdg {{ postgresql_major }}" |
12 | | - state: present |
13 | | - filename: postgresql-pgdg |
| 15 | + state: 'present' |
14 | 16 |
|
15 | 17 | - name: PostgREST - install system dependencies |
16 | | - apt: |
| 18 | + ansible.builtin.apt: |
17 | 19 | package: |
18 | | - - libpq5 |
19 | 20 | - libnuma-dev |
20 | | - update_cache: yes |
21 | | - state: present |
| 21 | + - libpq5 |
| 22 | + update_cache: true |
| 23 | + state: 'present' |
22 | 24 |
|
23 | | -- name: PostgREST - verify libpq5 version |
24 | | - shell: dpkg -l libpq5 | grep '^ii' | awk '{print $3}' |
25 | | - register: libpq5_version |
26 | | - changed_when: false |
| 25 | +- name: PostgREST - grab the list of installed packages |
| 26 | + ansible.builtin.package_facts: |
27 | 27 |
|
28 | 28 | - name: Show installed libpq5 version |
29 | | - debug: |
30 | | - msg: "Installed libpq5 version: {{ libpq5_version.stdout }}" |
| 29 | + ansible.builtin.debug: |
| 30 | + msg: "Installed libpq5 version: {{ ansible_facts['packages']['libpq5']['version'] }}" |
31 | 31 |
|
32 | 32 | - name: PostgREST - remove Postgres PPA gpg key |
33 | | - apt_key: |
34 | | - url: https://www.postgresql.org/media/keys/ACCC4CF8.asc |
35 | | - state: absent |
| 33 | + ansible.builtin.apt_key: |
| 34 | + state: 'absent' |
| 35 | + url: 'https://www.postgresql.org/media/keys/ACCC4CF8.asc' |
36 | 36 |
|
37 | 37 | - name: PostgREST - remove Postgres PPA |
38 | | - apt_repository: |
| 38 | + ansible.builtin.apt_repository: |
39 | 39 | repo: "deb http://apt.postgresql.org/pub/repos/apt/ noble-pgdg {{ postgresql_major }}" |
40 | | - state: absent |
| 40 | + state: 'absent' |
41 | 41 |
|
42 | 42 | - name: postgis - ensure dependencies do not get autoremoved |
43 | | - shell: | |
44 | | - set -e |
45 | | - apt-mark manual libpq5* |
46 | | - apt-mark manual libnuma* |
47 | | - apt-mark auto libnuma*-dev |
| 43 | + ansible.builtin.command: |
| 44 | + cmd: apt-mark manual libpq5* libnuma* |
| 45 | + |
| 46 | +- name: postgis - allow libnuma-dev to be autoremoved |
| 47 | + ansible.builtin.command: |
| 48 | + cmd: apt-mark auto libnuma*-dev |
48 | 49 |
|
49 | 50 | - name: PostgREST - download ubuntu binary archive (arm) |
50 | | - get_url: |
51 | | - url: "https://github.com/PostgREST/postgrest/releases/download/v{{ postgrest_release }}/postgrest-v{{ postgrest_release }}-ubuntu-aarch64.tar.xz" |
52 | | - dest: /tmp/postgrest.tar.xz |
| 51 | + ansible.builtin.get_url: |
53 | 52 | checksum: "{{ postgrest_arm_release_checksum }}" |
| 53 | + dest: '/tmp/postgrest.tar.xz' |
54 | 54 | timeout: 60 |
55 | | - when: platform == "arm64" |
56 | | - |
57 | | -- name: PostgREST - download ubuntu binary archive (x86) |
58 | | - get_url: |
59 | | - url: "https://github.com/PostgREST/postgrest/releases/download/v{{ postgrest_release }}/postgrest-v{{ postgrest_release }}-linux-static-x86-64.tar.xz" |
60 | | - dest: /tmp/postgrest.tar.xz |
61 | | - checksum: "{{ postgrest_x86_release_checksum }}" |
62 | | - timeout: 60 |
63 | | - when: platform == "amd64" |
| 55 | + url: "https://github.com/PostgREST/postgrest/releases/download/v{{ postgrest_release }}/postgrest-v{{ postgrest_release }}-{{ download_binary }}.tar.xz" |
| 56 | + vars: |
| 57 | + download_binary: >- |
| 58 | + {%- if platform == "arm64" -%} |
| 59 | + ubuntu-aarch64 |
| 60 | + {%- elif platform == "amd64" -%} |
| 61 | + inux-static-x86-64 |
| 62 | + {%- endif -%} |
64 | 63 |
|
65 | 64 | - name: PostgREST - unpack archive in /opt |
66 | | - unarchive: |
67 | | - remote_src: yes |
68 | | - src: /tmp/postgrest.tar.xz |
69 | | - dest: /opt |
70 | | - owner: postgrest |
| 65 | + ansible.builtin.unarchive: |
| 66 | + dest: '/opt' |
71 | 67 | mode: '0755' |
| 68 | + owner: 'postgrest' |
| 69 | + remote_src: true |
| 70 | + src: '/tmp/postgrest.tar.xz' |
72 | 71 |
|
73 | 72 | - name: create directories |
74 | | - file: |
75 | | - state: directory |
76 | | - owner: postgrest |
77 | | - group: postgrest |
| 73 | + ansible.builtin.file: |
| 74 | + group: 'postgrest' |
78 | 75 | mode: '0775' |
79 | | - path: /etc/postgrest |
| 76 | + owner: 'postgrest' |
| 77 | + path: '/etc/postgrest' |
| 78 | + state: 'directory' |
80 | 79 |
|
81 | 80 | - name: empty files |
82 | | - file: |
83 | | - state: touch |
84 | | - owner: postgrest |
85 | | - group: postgrest |
86 | | - path: /etc/postgrest/{{ item }} |
87 | | - with_items: |
| 81 | + ansible.builtin.file: |
| 82 | + group: 'postgrest' |
| 83 | + owner: 'postgrest' |
| 84 | + path: "/etc/postgrest/{{ empty_item }}" |
| 85 | + state: 'touch' |
| 86 | + loop: |
88 | 87 | - base.conf |
89 | 88 | - generated.conf |
| 89 | + loop_control: |
| 90 | + loop_var: 'empty_item' |
90 | 91 |
|
91 | 92 | - name: create conf merging script |
92 | | - copy: |
| 93 | + ansible.builtin.copy: |
93 | 94 | content: | |
94 | 95 | #! /usr/bin/env bash |
95 | 96 | set -euo pipefail |
96 | 97 | set -x |
97 | 98 | cd "$(dirname "$0")" |
98 | 99 | cat $@ > merged.conf |
99 | | - dest: /etc/postgrest/merge.sh |
100 | | - mode: 0750 |
101 | | - owner: postgrest |
102 | | - group: postgrest |
| 100 | + dest: '/etc/postgrest/merge.sh' |
| 101 | + group: 'postgrest' |
| 102 | + mode: '0750' |
| 103 | + owner: 'postgrest' |
103 | 104 |
|
104 | 105 | - name: PostgREST - create service files |
105 | | - template: |
106 | | - src: files/{{ item }}.j2 |
107 | | - dest: /etc/systemd/system/{{ item }} |
108 | | - with_items: |
| 106 | + ansible.builtin.template: |
| 107 | + dest: "/etc/systemd/system/{{ svc_item }}" |
| 108 | + src: "files/{{ svc_item }}.j2" |
| 109 | + loop: |
109 | 110 | - postgrest.service |
110 | 111 | - postgrest-optimizations.service |
| 112 | + loop_control: |
| 113 | + loop_var: 'svc_item' |
111 | 114 |
|
112 | 115 | - name: PostgREST - reload systemd |
113 | | - systemd: |
114 | | - daemon_reload: yes |
| 116 | + ansible.builtin.systemd_service: |
| 117 | + daemon_reload: true |
0 commit comments