Skip to content

Conversation

@patchback
Copy link

@patchback patchback bot commented Dec 4, 2025

This is a backport of PR #865 as merged into main (de36216).

SUMMARY

Fixes #864

Fixes postgresql_db "session_role" behavior when state is dump/restore for binary (.pgc) archives.
It was being ignored but now it behaves as intended by pg_dump/pg_restore

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

postgresql_db

ADDITIONAL INFORMATION

When pg_dump is used, the --role parameter is used to switch to a different user/role that has sufficient permissions to perform the dump.

When pg_restore is used, the --role parameter, in combination with --no-owner, allows you to restore the objects contained in the archive under new ownership (the one specified with --role).

Up to now, whenever pg_dump/pg_restore was used, the session_role parameter was being ignored and it would give surprising results (or errors).

Now the session_role below will be relayed as the --role parameter for pg_dump/pg_restore.

- name: pg_restore archive on dst_db with session_role
  postgresql_db:
    login_user: postgres
    name: dst_db
    state: restore
    target: /tmp/archive.pgc
    session_role: restoration_role
    target_opts: "--no-owner"

I chose to create a new test python module for this feature, as it seemed cleaner and less intrusive with regards to the current integration tests.

@Andersson007
Copy link
Collaborator

ignoring failures against the Remote targets we are removing in #904

@Andersson007
Copy link
Collaborator

@gspanos hi, this is a backport PR to version 3, I see integration test failures, would you like to take a look?
I won't include it in 3.14.3 I'm releasing right now, but we can do it for the next one if we tackle the failures

@Andersson007 Andersson007 marked this pull request as draft December 4, 2025 07:23
@gspanos
Copy link
Contributor

gspanos commented Dec 4, 2025

@Andersson007 sure, I'll take a look

@Andersson007
Copy link
Collaborator

@Andersson007 sure, I'll take a look

@gspanos great thanks! Please ignore RH 8.8 and RH 9.3 failures: we've removed those checks as obsolete in another PR, FYI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants