initial commit
This commit is contained in:
commit
13eace9ce9
219 files changed
+6918
No files matched your search
@@ -0,0 +1,6 @@
|
||||
---
|
||||
- name: restart postgresql
|
||||
ansible.builtin.systemd_service:
|
||||
name: postgresql@17-main
|
||||
state: restarted
|
||||
enabled: true
|
||||
@@ -0,0 +1,68 @@
|
||||
---
|
||||
- name: install postgresql
|
||||
ansible.builtin.apt:
|
||||
name: "{{ item }}"
|
||||
state: latest
|
||||
update_cache: true
|
||||
loop:
|
||||
- postgresql
|
||||
- postgresql-contrib
|
||||
notify: restart postgresql
|
||||
|
||||
- name: ensure postgresql data directory is a mountpoint
|
||||
ansible.builtin.command: mountpoint -q /var/lib/postgresql
|
||||
register: vw_mountpoint
|
||||
failed_when: false
|
||||
changed_when: false
|
||||
|
||||
- name: stop postgresql before relocating data
|
||||
ansible.builtin.systemd:
|
||||
name: postgresql
|
||||
state: stopped
|
||||
when: vw_mountpoint.rc != 0
|
||||
|
||||
- name: remove default postgresql data directory
|
||||
ansible.builtin.file:
|
||||
path: /var/lib/postgresql/
|
||||
state: absent
|
||||
when: vw_mountpoint.rc != 0
|
||||
|
||||
- name: ensure postgres data source directory exists
|
||||
ansible.builtin.file:
|
||||
path: /mnt/pgsql/data
|
||||
state: directory
|
||||
owner: postgres
|
||||
group: postgres
|
||||
mode: "0755"
|
||||
|
||||
- name: bind mount postgres data directory
|
||||
ansible.posix.mount:
|
||||
path: /var/lib/postgresql
|
||||
src: /mnt/pgsql/data
|
||||
fstype: none
|
||||
opts: bind
|
||||
state: mounted
|
||||
notify: restart postgresql
|
||||
|
||||
- name: set postgres data directory ownership
|
||||
ansible.builtin.file:
|
||||
path: /mnt/pgsql/data
|
||||
owner: postgres
|
||||
group: postgres
|
||||
recurse: true
|
||||
|
||||
- name: configure postgres
|
||||
ansible.builtin.lineinfile:
|
||||
path: /etc/postgresql/17/main/postgresql.conf
|
||||
regexp: "^#?listen_addresses\\s*="
|
||||
line: "listen_addresses = '*'"
|
||||
state: present
|
||||
notify: restart postgresql
|
||||
|
||||
- name: configure pg_hba
|
||||
ansible.builtin.lineinfile:
|
||||
path: /etc/postgresql/17/main/pg_hba.conf
|
||||
line: "host all all {{ hostvars[item].ip }}/32 scram-sha-256"
|
||||
state: present
|
||||
loop: "{{ db_clients | default([]) }}"
|
||||
notify: restart postgresql
|
||||
Reference in new issue
Block a user