mirror of
https://github.com/cole-maxwell1/todo-hetzner.git
synced 2026-10-27 19:02:49 -05:00
ops(ansible): harden provisioning and restore automation
Fail before host changes when required deployment variables are missing. Precreate the PostgreSQL temporary directory and escape Bash syntax during Jinja rendering.
This commit is contained in:
@@ -1,4 +1,12 @@
|
||||
---
|
||||
- name: Create PostgreSQL Ansible temporary directory
|
||||
ansible.builtin.file:
|
||||
path: /var/lib/pgsql/.ansible/tmp
|
||||
state: directory
|
||||
owner: postgres
|
||||
group: postgres
|
||||
mode: "0700"
|
||||
|
||||
- name: Initialize PostgreSQL data directory
|
||||
ansible.builtin.command:
|
||||
argv: [postgresql-setup, --initdb]
|
||||
|
||||
@@ -17,7 +17,9 @@ systemctl stop "$POSTGRES_SERVICE"
|
||||
|
||||
shopt -s dotglob nullglob
|
||||
contents=("$PGDATA"/*)
|
||||
{% raw %}
|
||||
if (( ${#contents[@]} > 0 )); then
|
||||
{% endraw %}
|
||||
rm -rf --one-file-system -- "${contents[@]}"
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user