|
1 |
| -- name: Copy extension packages |
2 |
| - copy: |
3 |
| - src: files/extensions/ |
4 |
| - dest: /tmp/extensions/ |
5 |
| - when: debpkg_mode |
| 1 | +- name: debpkg_mode actions |
| 2 | + when: |
| 3 | + - debpkg_mode |
| 4 | + block: |
| 5 | + - name: Copy extension packages |
| 6 | + ansible.builtin.copy: |
| 7 | + dest: '/tmp/extensions/' |
| 8 | + src: 'files/extensions/' |
6 | 9 |
|
7 |
| -# Builtin apt module does not support wildcard for deb paths |
8 |
| -- name: Install extensions |
9 |
| - shell: | |
10 |
| - set -e |
11 |
| - apt-get update |
12 |
| - apt-get install -y --no-install-recommends /tmp/extensions/*.deb |
13 |
| - when: debpkg_mode |
| 10 | + - name: Install extensions |
| 11 | + ansible.builtin.apt: |
| 12 | + deb: "{{ deb_item }}" |
| 13 | + force_apt_get: true |
| 14 | + install_recommends: false |
| 15 | + state: 'present' |
| 16 | + update_cache: true |
| 17 | + loop_control: |
| 18 | + loop_var: 'deb_item' |
| 19 | + with_fileglob: |
| 20 | + - '/tmp/extensions/*.deb' |
14 | 21 |
|
15 |
| -- name: pgsodium - determine postgres bin directory |
16 |
| - shell: pg_config --bindir |
17 |
| - register: pg_bindir_output |
18 |
| - when: debpkg_mode |
19 |
| - |
20 |
| -- set_fact: |
21 |
| - pg_bindir: "{{ pg_bindir_output.stdout }}" |
22 |
| - when: debpkg_mode |
| 22 | + - name: pgsodium - determine PostgreSQL bin directory |
| 23 | + ansible.builtin.command: |
| 24 | + cmd: pg_config --bindir |
| 25 | + changed_when: false |
| 26 | + register: 'pg_bindir_output' |
| 27 | + |
| 28 | + - name: store the PostgreSQL bin dir as a fact |
| 29 | + ansible.builtin.set_fact: |
| 30 | + pg_bindir: "{{ pg_bindir_output['stdout'] }}" |
23 | 31 |
|
24 |
| -- name: pgsodium - set pgsodium.getkey_script |
25 |
| - become: yes |
26 |
| - lineinfile: |
27 |
| - path: /etc/postgresql/postgresql.conf |
28 |
| - state: present |
29 |
| - # script is expected to be placed by finalization tasks for different target platforms |
30 |
| - line: pgsodium.getkey_script= '{{ pg_bindir }}/pgsodium_getkey.sh' |
31 |
| - when: debpkg_mode |
| 32 | + - name: pgsodium - set pgsodium.getkey_script |
| 33 | + ansible.builtin.lineinfile: |
| 34 | + path: '/etc/postgresql/postgresql.conf' |
| 35 | + # script is expected to be placed by finalization tasks for different target platforms |
| 36 | + line: pgsodium.getkey_script= '{{ pg_bindir }}/pgsodium_getkey.sh' |
| 37 | + state: 'present' |
| 38 | + become: true |
32 | 39 |
|
33 |
| -# supautils |
34 |
| -- name: supautils - add supautils to session_preload_libraries |
35 |
| - become: yes |
36 |
| - replace: |
37 |
| - path: /etc/postgresql/postgresql.conf |
38 |
| - regexp: "#session_preload_libraries = ''" |
39 |
| - replace: session_preload_libraries = 'supautils' |
40 |
| - when: debpkg_mode or stage2_nix |
| 40 | +- name: debpkg_mode or stage2_nix actions |
| 41 | + when: |
| 42 | + - (debpkg_mode or stage2_nix) |
| 43 | + block: |
| 44 | + # supautils |
| 45 | + - name: supautils - add supautils to session_preload_libraries |
| 46 | + ansible.builtin.replace: |
| 47 | + path: '/etc/postgresql/postgresql.conf' |
| 48 | + regexp: "#session_preload_libraries = ''" |
| 49 | + replace: "session_preload_libraries = 'supautils'" |
| 50 | + become: true |
41 | 51 |
|
42 |
| -- name: supautils - write custom supautils.conf |
43 |
| - template: |
44 |
| - src: "files/postgresql_config/supautils.conf.j2" |
45 |
| - dest: /etc/postgresql-custom/supautils.conf |
46 |
| - mode: 0664 |
47 |
| - owner: postgres |
48 |
| - group: postgres |
49 |
| - when: debpkg_mode or stage2_nix |
| 52 | + - name: supautils - write custom supautils.conf |
| 53 | + ansible.builtin.template: |
| 54 | + dest: '/etc/postgresql-custom/supautils.conf' |
| 55 | + mode: '0664' |
| 56 | + group: 'postgres' |
| 57 | + owner: 'postgres' |
| 58 | + src: 'files/postgresql_config/supautils.conf.j2' |
50 | 59 |
|
51 |
| -- name: supautils - copy extension custom scripts |
52 |
| - copy: |
53 |
| - src: files/postgresql_extension_custom_scripts/ |
54 |
| - dest: /etc/postgresql-custom/extension-custom-scripts |
55 |
| - become: yes |
56 |
| - when: debpkg_mode or stage2_nix |
| 60 | + - name: supautils - copy extension custom scripts |
| 61 | + ansible.builtin.copy: |
| 62 | + dest: '/etc/postgresql-custom/extension-custom-scripts' |
| 63 | + src: 'files/postgresql_extension_custom_scripts/' |
| 64 | + become: true |
57 | 65 |
|
58 |
| -- name: supautils - chown extension custom scripts |
59 |
| - file: |
60 |
| - mode: 0775 |
61 |
| - owner: postgres |
62 |
| - group: postgres |
63 |
| - path: /etc/postgresql-custom/extension-custom-scripts |
64 |
| - recurse: yes |
65 |
| - become: yes |
66 |
| - when: debpkg_mode or stage2_nix |
| 66 | + - name: supautils - chown extension custom scripts |
| 67 | + ansible.builtin.file: |
| 68 | + group: 'postgres' |
| 69 | + mode: '0775' |
| 70 | + owner: 'postgres' |
| 71 | + path: '/etc/postgresql-custom/extension-custom-scripts' |
| 72 | + recurse: true |
| 73 | + become: true |
67 | 74 |
|
68 |
| -- name: supautils - include /etc/postgresql-custom/supautils.conf in postgresql.conf |
69 |
| - become: yes |
70 |
| - replace: |
71 |
| - path: /etc/postgresql/postgresql.conf |
72 |
| - regexp: "#include = '/etc/postgresql-custom/supautils.conf'" |
73 |
| - replace: "include = '/etc/postgresql-custom/supautils.conf'" |
74 |
| - when: debpkg_mode or stage2_nix |
| 75 | + - name: supautils - include /etc/postgresql-custom/supautils.conf in postgresql.conf |
| 76 | + ansible.builtin.replace: |
| 77 | + path: '/etc/postgresql/postgresql.conf' |
| 78 | + regexp: "#include = '/etc/postgresql-custom/supautils.conf'" |
| 79 | + replace: "include = '/etc/postgresql-custom/supautils.conf'" |
| 80 | + become: true |
75 | 81 |
|
76 | 82 | - name: Cleanup - extension packages
|
77 |
| - file: |
78 |
| - path: /tmp/extensions |
79 |
| - state: absent |
80 |
| - when: debpkg_mode |
| 83 | + ansible.builtin.file: |
| 84 | + path: '/tmp/extensions' |
| 85 | + state: 'absent' |
| 86 | + when: |
| 87 | + - debpkg_mode |
0 commit comments