diff --git a/tasks/configure.yml b/tasks/configure.yml index be61d3e..87d30f9 100644 --- a/tasks/configure.yml +++ b/tasks/configure.yml @@ -36,8 +36,8 @@ - name: Create PostgreSQL data directory ansible.builtin.file: path: "{{ _postgresql_datadir }}" - owner: "{{ postgresql_user }}" - group: "{{ postgresql_group }}" + owner: "{{ _postgresql_user }}" + group: "{{ _postgresql_group }}" state: directory mode: 0700 @@ -46,7 +46,7 @@ cmd: "{{ _postgresql_bindir }}/initdb -D {{ _postgresql_datadir }}" creates: "{{ _postgresql_datadir }}/PG_VERSION" become: true - become_user: "{{ postgresql_user }}" + become_user: "{{ _postgresql_user }}" when: _postgresql_initdb | bool - name: Enable PostgreSQL checksums @@ -59,16 +59,16 @@ ansible.builtin.file: path: "{{ _postgresql_conf_include }}" state: directory - owner: "{{ postgresql_user }}" - group: "{{ postgresql_group }}" + owner: "{{ _postgresql_user }}" + group: "{{ _postgresql_group }}" mode: 0755 - name: Manage PostgreSQL ansible include config ansible.builtin.copy: dest: "{{ _postgresql_conf_ansible }}" content: "{{ postgresql_conf_ansible }}" - owner: "{{ postgresql_user }}" - group: "{{ postgresql_group }}" + owner: "{{ _postgresql_user }}" + group: "{{ _postgresql_group }}" mode: 0644 when: postgresql_conf_ansible is defined notify: postgresql_reload @@ -85,8 +85,8 @@ path: "{{ _postgresql_conf_local }}" state: touch modification_time: preserve - owner: "{{ postgresql_user }}" - group: "{{ postgresql_group }}" + owner: "{{ _postgresql_user }}" + group: "{{ _postgresql_group }}" mode: 0644 changed_when: false @@ -106,8 +106,8 @@ ansible.builtin.template: src: postgresql.conf.j2 dest: "{{ _postgresql_conf_main }}" - owner: "{{ postgresql_user }}" - group: "{{ postgresql_group }}" + owner: "{{ _postgresql_user }}" + group: "{{ _postgresql_group }}" backup: true mode: 0644 notify: postgresql_restart @@ -116,8 +116,8 @@ ansible.builtin.template: src: pg_hba.conf.j2 dest: "{{ _postgresql_conf_hba }}" - owner: "{{ postgresql_user }}" - group: "{{ postgresql_group }}" + owner: "{{ _postgresql_user }}" + group: "{{ _postgresql_group }}" backup: true mode: 0644 vars: diff --git a/tasks/databases.yml b/tasks/databases.yml index 96e0e29..f478b86 100644 --- a/tasks/databases.yml +++ b/tasks/databases.yml @@ -10,13 +10,13 @@ encoding: "{{ item.encoding | default('UTF-8') }}" template: "{{ item.template | default('template0') }}" port: "{{ item.port | default(omit) }}" - owner: "{{ item.owner | default(postgresql_user) }}" + owner: "{{ item.owner | default(_postgresql_user) }}" state: "{{ item.state | default('present') }}" loop_control: label: "{{ item.name }}" loop: "{{ postgresql_databases }}" become: true - become_user: "{{ postgresql_user }}" + become_user: "{{ _postgresql_user }}" - name: Manage PostgreSQL database privileges community.postgresql.postgresql_privs: @@ -38,6 +38,6 @@ label: "{{ _database.name }}" loop: "{{ postgresql_databases | subelements('roles', skip_missing='yes') }}" become: true - become_user: "{{ postgresql_user }}" + become_user: "{{ _postgresql_user }}" environment: PGOPTIONS: "{{ _postgresql_pgoptions }}" diff --git a/tasks/roles.yml b/tasks/roles.yml index 840a5c5..15c8aa7 100644 --- a/tasks/roles.yml +++ b/tasks/roles.yml @@ -10,7 +10,7 @@ label: "{{ item.name }}" loop: "{{ postgresql_roles }}" become: true - become_user: "{{ postgresql_user }}" + become_user: "{{ _postgresql_user }}" environment: PGOPTIONS: "{{ _postgresql_pgoptions }}" no_log: "{{ postgresql_nolog }}" @@ -29,7 +29,7 @@ label: "{{ _role.name }} - {{ _group_name }} - {{ _group_state }}" loop: "{{ postgresql_roles | subelements('groups', skip_missing='yes') }}" become: true - become_user: "{{ postgresql_user }}" + become_user: "{{ _postgresql_user }}" environment: PGOPTIONS: "{{ _postgresql_pgoptions }}" no_log: "{{ postgresql_nolog }}" diff --git a/tasks/vars.yml b/tasks/vars.yml index 2f6de60..68d3e86 100644 --- a/tasks/vars.yml +++ b/tasks/vars.yml @@ -6,6 +6,8 @@ ansible.builtin.set_fact: _postgresql_package_name: "{{ postgresql_package_name | default(_default_package_name) }}" _postgresql_service_name: "{{ postgresql_service_name | default(_default_service) }}" + _postgresql_user: "{{ postgresql_user }}" + _postgresql_group: "{{ postgresql_group }}" _postgresql_bindir: "{{ __postgresql_bindir | nephelaiio.plugins.sorted_get(_conf_search) }}" _postgresql_confdir: "{{ _conf_confdir }}" _postgresql_datadir: "{{ _conf_datadir }}"