xoxys.postgres/tasks/main.yml

63 lines
1.8 KiB
YAML
Raw Normal View History

2018-10-14 21:17:40 +00:00
---
2024-08-13 07:40:06 +00:00
- name: Create network specs
ansible.builtin.template:
2024-08-13 08:56:02 +00:00
src: etc/containers/systemd/{{ postgres_network }}.j2
dest: "/etc/containers/systemd/{{ postgres_network }}"
2024-08-13 07:40:06 +00:00
owner: root
group: root
mode: "0640"
when: postgres_network | splitext | last == ".network"
notify: __postgres_restart
2022-04-04 19:51:15 +00:00
2024-08-13 07:40:06 +00:00
- name: Create container volumes
containers.podman.podman_volume:
name: "{{ item.name }}"
options: "{{ item.options | default(omit) }}"
state: "{{ item.state | default('present') }}"
loop: "{{ postgres_volumes }}"
loop_control:
label: "{{ item.name }}"
when: item.type | default("volume") | lower == "volume"
register: __postgres_volumes_raw
2022-04-04 19:51:15 +00:00
2024-08-13 07:40:06 +00:00
- 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') }}"
2024-08-13 07:40:06 +00:00
- name: Deploy postgres env files
ansible.builtin.template:
src: "etc/containers/systemd/{{ item }}.j2"
dest: "/etc/containers/systemd/{{ item }}"
owner: root
group: root
mode: "0640"
loop:
- postgres.env
- postgres.sys.env
notify: __postgres_restart
2024-08-13 07:40:06 +00:00
- name: Create container specs
ansible.builtin.template:
src: etc/containers/systemd/postgres.container.j2
dest: "/etc/containers/systemd/postgres.container"
owner: root
group: root
mode: "0640"
notify: __postgres_restart
2024-08-13 07:40:06 +00:00
- name: Deploy init-user-db
ansible.builtin.copy:
src: init-user-db.sh
dest: "{{ __postgres_volumes_map['postgres-initdb'] }}"
owner: "{{ postgres_uid }}"
group: "{{ postgres_gid }}"
mode: "0644"
when: "'postgres-initdb' in __postgres_volumes_map"
2024-08-13 07:32:28 +00:00
2024-08-13 07:40:06 +00:00
- name: Ensure service state
ansible.builtin.service:
name: "postgres.service"
state: started
daemon_reload: True
enabled: True