diff --git a/playbooks/test_psql.yml b/playbooks/test_psql.yml new file mode 100644 index 0000000000..bfad48662d --- /dev/null +++ b/playbooks/test_psql.yml @@ -0,0 +1,36 @@ +--- +- name: try updating postgresql db table ownership + hosts: postgresql_{{ runtime_env | default('staging') }} + remote_user: pulsys + become: true + vars: + - project_name: pulmap + + vars_files: + - ../group_vars/{{ project_name }}/{{ app_runtime_env | default(runtime_env) | default('staging') }}.yml + # - ../group_vars/{{ project_name }}/main.yml # some roles have this + - ../group_vars/{{ project_name }}/vault.yml + tasks: + - name: PostgreSQL | change postgresql database owner + community.postgresql.postgresql_owner: + db: "{{ application_db_name }}" + port: "{{ postgres_port }}" + login_host: "{{ postgres_host }}" + login_user: "{{ postgres_admin_user }}" + login_password: "{{ postgres_admin_password }}" + new_owner: "{{ application_dbuser_name }}" + obj_type: "{{ item }}" + with_items: + - database + - table + - tablespace + - view + when: + - running_on_server + - not postgresql_is_local + changed_when: false + run_once: true + + + + diff --git a/roles/postgresql/tasks/create_users.yml b/roles/postgresql/tasks/create_users.yml index 9dca9ea956..72802ff034 100644 --- a/roles/postgresql/tasks/create_users.yml +++ b/roles/postgresql/tasks/create_users.yml @@ -39,15 +39,19 @@ run_once: true - name: PostgreSQL | change postgresql database owner - community.postgresql.postgresql_db: - name: "{{ application_db_name }}" + community.postgresql.postgresql_owner: + db: "{{ application_db_name }}" port: "{{ postgres_port }}" login_host: "{{ postgres_host }}" login_user: "{{ postgres_admin_user }}" login_password: "{{ postgres_admin_password }}" - encoding: "UTF-8" - state: "present" - owner: "{{ application_dbuser_name }}" + new_owner: "{{ application_dbuser_name }}" + obj_type: "{{ item }}" + with_items: + - database + - table + - tablespace + - view when: - running_on_server - not postgresql_is_local