Files
playbooks/nextcloud/roles/postgres/tasks/main.yaml
T
tanshu 476a6d7cd0 Cut the comment bloat from the Podman playbooks
Comment blocks now stay within three lines and explain only the non-obvious. Long histories, include examples, and commented-out code are gone. No task, key, or value changed; the only data change is comment text inside the generated unit files.
2026-10-18 22:10:57 +05:30

35 lines
1.4 KiB
YAML

---
- name: Attach Nextcloud to Postgres
ansible.builtin.include_tasks: "{{ playbook_dir }}/../postgres/roles/attach/tasks/main.yaml"
# The restart that joins Postgres to nextcloud_net is a handler, so flush it before the app starts. This also applies the queued Caddy restart.
- name: Apply the network change before starting Nextcloud
ansible.builtin.meta: flush_handlers
# On a fresh cluster the installer would fail without this database, and the retry covers the restart the flush did.
- name: Check whether the {{ pg_database }} database exists
ansible.builtin.command: >-
podman exec -e PGPASSWORD={{ pg_password }} {{ postgres_container }}
psql -U {{ pg_user }} -d postgres -tAc
"select datname from pg_database where datname = '{{ pg_database }}'"
register: nextcloud_db
until: nextcloud_db.rc == 0
retries: 12
delay: 5
changed_when: false
failed_when: false
- name: Fail if the shared Postgres is not reachable
ansible.builtin.assert:
that: nextcloud_db.rc == 0
fail_msg: >-
{{ postgres_container }} did not answer. Run postgres/playbook.yml on this
host first — this play attaches to that cluster and creates its own database
in it.
- name: Create the {{ pg_database }} database
ansible.builtin.command: >-
podman exec -e PGPASSWORD={{ pg_password }} {{ postgres_container }}
createdb -U {{ pg_user }} -O {{ pg_user }} {{ pg_database }}
when: nextcloud_db.stdout | trim | length == 0