Fix database deploy idempotency

This commit is contained in:
Wojciech Kozlowski 2023-08-17 21:46:38 +02:00
parent 00b0ccf4cb
commit 4340b894aa

View File

@ -4,6 +4,25 @@
name: "services/include" name: "services/include"
vars_from: "user" vars_from: "user"
- name: "stat the pgadmin password file"
ansible.builtin.stat:
path: "{{ services_service_user_home }}/.config/service/pgadmin.password"
register: services_deploy_database_pgadmin_password_file_stat
- name: "configure pgadmin password"
ansible.builtin.template:
src: "./pgadmin/pgadmin.password"
dest: "{{ services_service_user_home }}/.config/service/pgadmin.password"
mode: 0600
# Being root allows ansible to read the file, determine the diff, and preserve the uid:gid.
become_user: "\
{% if services_deploy_database_pgadmin_password_file_stat.stat.exists %}\
root\
{% else %}\
{{ services_service_user_name }}\
{% endif %}"
register: services_deploy_database_pgadmin_password_file
- block: - block:
- name: "configure postgres password" - name: "configure postgres password"
@ -13,13 +32,6 @@
mode: 0600 mode: 0600
register: services_deploy_database_postgres_password_file register: services_deploy_database_postgres_password_file
- name: "configure pgadmin password"
ansible.builtin.template:
src: "./pgadmin/pgadmin.password"
dest: "{{ services_service_user_home }}/.config/service/pgadmin.password"
mode: 0600
register: services_deploy_database_pgadmin_password_file
- name: "configure systemd service" - name: "configure systemd service"
ansible.builtin.template: ansible.builtin.template:
src: "./systemd/{{ item }}" src: "./systemd/{{ item }}"