Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testing a new approach to psql table ownership #3334

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions playbooks/test_psql.yml
Original file line number Diff line number Diff line change
@@ -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




14 changes: 9 additions & 5 deletions roles/postgresql/tasks/create_users.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down