This commit is contained in:
Robert Kaussow 2024-08-13 09:40:06 +02:00
parent ad3a53bed7
commit e340d11ad5
Signed by: xoxys
GPG Key ID: 4E692A2EAECC03C0
2 changed files with 56 additions and 59 deletions

View File

@ -1,6 +1,6 @@
---
- name: Restart PostgreSQL
service:
ansible.builtin.service:
name: postgres
state: restarted
daemon_reload: True

View File

@ -1,7 +1,6 @@
---
- block:
- name: Create network specs
template:
- name: Create network specs
ansible.builtin.template:
src: etc/containers/systemd/postgres.network.j2
dest: "/etc/containers/systemd/postgres.network"
owner: root
@ -10,7 +9,7 @@
when: postgres_network | splitext | last == ".network"
notify: __postgres_restart
- name: Create container volumes
- name: Create container volumes
containers.podman.podman_volume:
name: "{{ item.name }}"
options: "{{ item.options | default(omit) }}"
@ -21,12 +20,12 @@
when: item.type | default("volume") | lower == "volume"
register: __postgres_volumes_raw
- name: Register container volumes map
set_fact:
- name: Register container volumes map
ansible.builtin.set_fact:
__postgres_volumes_map: "{{ __postgres_volumes_raw.results | json_query('[].volume') | items2dict(key_name='Name', value_name='Mountpoint') }}"
- name: Deploy postgres env files
template:
- name: Deploy postgres env files
ansible.builtin.template:
src: "etc/containers/systemd/{{ item }}.j2"
dest: "/etc/containers/systemd/{{ item }}"
owner: root
@ -37,8 +36,8 @@
- postgres.sys.env
notify: __postgres_restart
- name: Create container specs
template:
- name: Create container specs
ansible.builtin.template:
src: etc/containers/systemd/postgres.container.j2
dest: "/etc/containers/systemd/postgres.container"
owner: root
@ -46,7 +45,7 @@
mode: "0640"
notify: __postgres_restart
- name: Deploy init-user-db
- name: Deploy init-user-db
ansible.builtin.copy:
src: init-user-db.sh
dest: "{{ __postgres_volumes_map['postgres-initdb'] }}"
@ -55,11 +54,9 @@
mode: "0644"
when: "'postgres-initdb' in __postgres_volumes_map"
- name: Ensure service state
systemd:
- name: Ensure service state
ansible.builtin.service:
name: "postgres.service"
state: started
daemon_reload: True
enabled: True
become: True
become_user: root