Skip to content

postgresql_pg_hba: fix false "changed" when called with "overwrite: true"#378

Merged
betanummeric merged 4 commits intoansible-collections:mainfrom
betanummeric:fix-pghba-unchanged-overwrite
Dec 2, 2022
Merged

postgresql_pg_hba: fix false "changed" when called with "overwrite: true"#378
betanummeric merged 4 commits intoansible-collections:mainfrom
betanummeric:fix-pghba-unchanged-overwrite

Conversation

@betanummeric
Copy link
Member

postgresql_pg_hba bugfix

fixes #376

  • When parsing the pg_hba.conf, trim whitespace between the rule and comment in the same line, to ensure equality tests work.
  • Determine whether something changed by checking if read and to-be-written rules differ. Previously the check was slightly different: When overwrite was enabled, the rule list was emptied and adding rules again counted as change.

@betanummeric betanummeric changed the title postgresql_pg_hba: fix false "changed" when called with "overwrite: true" [draft] postgresql_pg_hba: fix false "changed" when called with "overwrite: true" Dec 1, 2022
@betanummeric betanummeric changed the title [draft] postgresql_pg_hba: fix false "changed" when called with "overwrite: true" postgresql_pg_hba: fix false "changed" when called with "overwrite: true" Dec 1, 2022
@betanummeric
Copy link
Member Author

betanummeric commented Dec 1, 2022

This is ready for review. A backport should not be needed as this only affects the overwrite: true case, which was introduced in v2.2.0.

Copy link
Collaborator

@Andersson007 Andersson007 left a comment

Choose a reason for hiding this comment

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

@betanummeric is it possible to cover the case with integration tests? If it's tricky, no problem

@betanummeric
Copy link
Member Author

It should be fairly easy to add a test, I can do it tomorrow.

…ain with the same arguments (having overwrite=true)
Copy link
Collaborator

@Andersson007 Andersson007 left a comment

Choose a reason for hiding this comment

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

LGTM

@nlvw thanks for reporting the issue!
@hunleyd thanks for reviewing!
@betanummeric thanks for fixing this! I think you can merge the PR yourself as there are approvals (choose "Squash and Merge", not the other options)

@betanummeric betanummeric merged commit f621dd4 into ansible-collections:main Dec 2, 2022
@betanummeric betanummeric deleted the fix-pghba-unchanged-overwrite branch December 9, 2022 14:00
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.

postgresql_pg_hba is not idempotent when used with overwrite and rules

4 participants