|
1 | 1 | - name: PG logging conf
|
2 |
| - template: |
3 |
| - src: files/postgresql_config/postgresql-csvlog.conf |
4 |
| - dest: /etc/postgresql/logging.conf |
5 |
| - group: postgres |
| 2 | + ansible.builtin.template: |
| 3 | + dest: '/etc/postgresql/logging.conf' |
| 4 | + group: 'postgres' |
| 5 | + src: 'files/postgresql_config/postgresql-csvlog.conf' |
6 | 6 |
|
7 | 7 | - name: UFW - Allow SSH connections
|
8 |
| - ufw: |
9 |
| - rule: allow |
10 |
| - name: OpenSSH |
| 8 | + community.general.ufw: |
| 9 | + name: 'OpenSSH' |
| 10 | + rule: 'allow' |
11 | 11 |
|
12 |
| -- name: UFW - Allow connections to postgreSQL (5432) |
13 |
| - ufw: |
14 |
| - rule: allow |
15 |
| - port: "5432" |
| 12 | +- name: UFW - Allow SSH/PostgreSQL connections |
| 13 | + community.general.ufw: |
| 14 | + port: '5432' |
| 15 | + rule: 'allow' |
16 | 16 |
|
17 |
| -- name: UFW - Allow connections to postgreSQL (6543) |
18 |
| - ufw: |
19 |
| - rule: allow |
20 |
| - port: "6543" |
| 17 | +- name: UFW - Allow PgBouncer connections |
| 18 | + community.general.ufw: |
| 19 | + port: '6543' |
| 20 | + rule: 'allow' |
21 | 21 | tags:
|
22 | 22 | - install-pgbouncer
|
23 | 23 |
|
24 |
| -- name: UFW - Allow connections to http (80) |
25 |
| - ufw: |
26 |
| - rule: allow |
27 |
| - port: http |
28 |
| - tags: |
29 |
| - - install-supabase-internal |
30 |
| - |
31 |
| -- name: UFW - Allow connections to https (443) |
32 |
| - ufw: |
33 |
| - rule: allow |
34 |
| - port: https |
| 24 | +- name: UFW - Allow HTTP/HTTPS connections |
| 25 | + community.general.ufw: |
| 26 | + port: "{{ port_item }}" |
| 27 | + rule: 'allow' |
| 28 | + loop: |
| 29 | + - 'http' |
| 30 | + - 'https' |
| 31 | + loop_control: |
| 32 | + loop_var: 'port_item' |
35 | 33 | tags:
|
36 |
| - - install-supabase-internal |
| 34 | + - install-supabase-internal |
37 | 35 |
|
38 | 36 | - name: UFW - Deny all other incoming traffic by default
|
39 |
| - ufw: |
40 |
| - state: enabled |
41 |
| - policy: deny |
42 |
| - direction: incoming |
| 37 | + community.general.ufw: |
| 38 | + direction: 'incoming' |
| 39 | + policy: 'deny' |
| 40 | + state: 'enabled' |
43 | 41 |
|
44 | 42 | - name: Move logrotate files to /etc/logrotate.d/
|
45 |
| - copy: |
46 |
| - src: "files/logrotate_config/{{ item.file }}" |
47 |
| - dest: "/etc/logrotate.d/{{ item.file }}" |
48 |
| - mode: "0700" |
49 |
| - owner: root |
| 43 | + ansible.builtin.copy: |
| 44 | + dest: "/etc/logrotate.d/{{ logrotate_item['file'] }}" |
| 45 | + mode: '0700' |
| 46 | + owner: 'root' |
| 47 | + src: "files/logrotate_config/{{ logrotate_item['file'] }}" |
50 | 48 | loop:
|
51 |
| - - { file: "logrotate-postgres-csv.conf" } |
52 |
| - - { file: "logrotate-postgres.conf" } |
53 |
| - - { file: "logrotate-walg.conf" } |
54 |
| - - { file: "logrotate-postgres-auth.conf" } |
| 49 | + - { file: 'logrotate-postgres.conf' } |
| 50 | + - { file: 'logrotate-postgres-auth.conf' } |
| 51 | + - { file: 'logrotate-postgres-csv.conf' } |
| 52 | + - { file: 'logrotate-walg.conf' } |
| 53 | + loop_control: |
| 54 | + loop_var: 'logrotate_item' |
55 | 55 |
|
56 |
| -- name: Ensure default Postgres logrotate config is removed |
57 |
| - file: |
58 |
| - path: /etc/logrotate.d/postgresql-common |
59 |
| - state: absent |
| 56 | +- name: Ensure default PostgreSQL logrotate config is removed |
| 57 | + ansible.builtin.file: |
| 58 | + path: '/etc/logrotate.d/postgresql-common' |
| 59 | + state: 'absent' |
60 | 60 |
|
61 | 61 | - name: Disable cron access
|
62 | 62 | copy:
|
63 |
| - src: files/cron.deny |
64 |
| - dest: /etc/cron.deny |
| 63 | + dest: '/etc/cron.deny' |
| 64 | + src: 'files/cron.deny' |
| 65 | + |
| 66 | +- name: Create logrotate.timer.d overrides dir |
| 67 | + become: true |
| 68 | + ansible.builtin.file: |
| 69 | + group: 'root' |
| 70 | + mode: '0755' |
| 71 | + owner: 'root' |
| 72 | + path: '/etc/systemd/system/logrotate.timer.d' |
| 73 | + state: 'directory' |
| 74 | + |
| 75 | +- name: Configure logrotate.timer.d overrides |
| 76 | + become: true |
| 77 | + community.general.ini_file: |
| 78 | + group: 'root' |
| 79 | + mode: '0644' |
| 80 | + no_extra_spaces: true |
| 81 | + option: 'OnCalendar' |
| 82 | + owner: 'root' |
| 83 | + path: '/etc/systemd/system/logrotate.timer.d/override.conf' |
| 84 | + section: 'Timer' |
| 85 | + state: 'present' |
| 86 | + value: '*:0/5' |
65 | 87 |
|
66 |
| -- name: Configure logrotation to run every hour |
67 |
| - shell: |
68 |
| - cmd: | |
69 |
| - cp /usr/lib/systemd/system/logrotate.timer /etc/systemd/system/logrotate.timer |
70 |
| - sed -i -e 's;daily;*:0/5;' /etc/systemd/system/logrotate.timer |
71 |
| - systemctl reenable logrotate.timer |
72 |
| - become: yes |
| 88 | +- name: Reload systemd and start logrotate timer |
| 89 | + become: true |
| 90 | + ansible.builtin.systemd_service: |
| 91 | + daemon_reload: true |
| 92 | + enabled: true |
| 93 | + name: 'logrotate.timer' |
| 94 | + state: 'restarted' |
73 | 95 |
|
74 | 96 | - name: import pgsodium_getkey script
|
75 |
| - template: |
76 |
| - src: files/pgsodium_getkey_readonly.sh.j2 |
| 97 | + ansible.builtin.template: |
77 | 98 | dest: "{{ pg_bindir }}/pgsodium_getkey.sh"
|
78 |
| - owner: postgres |
79 |
| - group: postgres |
80 |
| - mode: 0700 |
81 |
| - when: debpkg_mode or stage2_nix |
| 99 | + group: 'postgres' |
| 100 | + mode: '0700' |
| 101 | + owner: 'postgres' |
| 102 | + src: 'files/pgsodium_getkey_readonly.sh.j2' |
| 103 | + when: |
| 104 | + - (debpkg_mode or stage2_nix) |
0 commit comments