Skip to content

Fix postgres execution not respecting configuration values - #69973

Closed
nicholas-rees wants to merge 1 commit into
saltstack:3008.xfrom
nicholas-rees:NRees/postgres-config
Closed

Fix postgres execution not respecting configuration values#69973
nicholas-rees wants to merge 1 commit into
saltstack:3008.xfrom
nicholas-rees:NRees/postgres-config

Conversation

@nicholas-rees

@nicholas-rees nicholas-rees commented Aug 8, 2026

Copy link
Copy Markdown

What does this PR do?

Modifies the postgres execution module to respect the configuration set by changing all calls from config.option to config.get and setting the string delimiters to colons.

As noted in the related issue I opened:

# salt-call config.option

Passed invalid arguments: option() missing 1 required positional argument: 'value'.

Usage:

Returns the setting for the specified config value. The priority for
matches is the same as in :py:func:`config.get <salt.modules.config.get>`,
only this function does not recurse into nested data structures. Another
difference between this function and :py:func:`config.get
<salt.modules.config.get>` is that it comes with a set of "sane defaults".
To view these, you can run the following command:

It seems like config.option is just the wrong function to use and config.get is the correct one.

Before this fix:

# salt-call postgres.psql_query "SELECT current_user, session_user;"
local:
    |_
      ----------
      current_user:
          postgres
      session_user:
          postgres

After:

# salt-call postgres.psql_query "SELECT current_user, session_user;"
local:
    |_
      ----------
      current_user:
          salt_admin
      session_user:
          salt_admin

I do not know if this should go in the 3006.x. I sort of suspect that it should but I have not tested this at all on 3006.x so I have made this PR. If you would like to change it to 3006.x let me know and I can do that work.

What issues does this PR fix or reference?

Fixes #69971

Previous Behavior

postgres module was not respecting the configuration set in either the pillars or minion configuration file.

New Behavior

postgres module now respects configuration values.

Merge requirements satisfied?

[NOTICE] Bug fixes or features added to Salt require tests.

Commits signed with GPG?

Yes

@nicholas-rees
nicholas-rees requested a review from a team as a code owner August 8, 2026 06:22

@twangboy twangboy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because config.option("postgres.bins_dir") uses . as a flat key lookup, switching to config.get("postgres:bins_dir") without specifying delimiter='.' means Salt will no longer match the exact configuration keys shown in its own module documentation.

All config.get calls should use delimiter="." to avoid breaking existing configs.

Also, when switching to config.get, any lookup for an option that requires a non-None fallback (like a default port 5432 or default database "postgres") should explicitly pass default=.... Otherwise, missing config keys silently return None into functions that might not be expecting None.

And yes, this should go onto 3006.x

Comment thread salt/modules/postgres.py
Helper function to locate various psql related binaries
"""
pg_bin_dir = __salt__["config.option"]("postgres.bins_dir")
pg_bin_dir = __salt__["config.get"]("postgres:bins_dir")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delimiter Syntax Change (postgres.bins_dir vs postgres:bins_dir)

  • Switching from config.option to config.get` changes the default string delimiter from .to:``.
  • If existing users have keys configured as postgres.bins_dir, postgres.host, or postgres.user in their minion configs, config.get("postgres:bins_dir") will fail to find them unless the delimiter='.' argument is passed or the lookups are explicitly structured to support legacy dot notation.
  • Standard Salt convention for config.get lookup with dot-separated string keys requires setting delimiter='.':
__salt__["config.get"]("postgres.bins_dir", delimiter=".")

Comment thread salt/modules/postgres.py
Comment on lines +159 to +160
"timeout": __salt__["config.get"](
"postgres:timeout", default=_DEFAULT_COMMAND_TIMEOUT_SECS

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing here, pass delimiter="."

Comment thread salt/modules/postgres.py
Comment on lines +265 to +266
timeout=__salt__["config.get"](
"postgres:timeout", default=_DEFAULT_COMMAND_TIMEOUT_SECS

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here: delimiter="."

@nicholas-rees
nicholas-rees deleted the NRees/postgres-config branch August 11, 2026 19:00
@nicholas-rees

Copy link
Copy Markdown
Author

Because I had to change the branch to 3006.x, I had to either force push, rename, or delete the previous branch in order to be sure the commits would line up. When doing so, that caused this PR to be closed.

You can find the new MR at #70013.

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.

2 participants