Skip to content

Use copy state instead of salt-call #256

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

Conversation

thomasrossetto
Copy link

Now it works also with salt-ssh.

Copy link
Contributor

@vutny vutny left a comment

Choose a reason for hiding this comment

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

Hi @thomasrossetto !

That was me who introduced the local file backup technique to this state. This a tricky problem, though.
The require state is not suitable here, because on the initial state run when the config file is not present (which is the case on some distros and upstream PG combination), nothing to backup.
Also, if the backup extension is not static, the new backup file would be made on each state state run.

You probably want to backup it only when changes are going to be made.
I suggest to look at prereq requisite, because I also consider that raw salt-call command doesn't look nice at all.
When I initially implemented it, I stumbled into some issues with older Salt releases. Probably for now it may not be the case anymore. See issue #148 and PR #149 .

Thanks!

@thomasrossetto
Copy link
Author

Hi @vutny !
I tried to replace with prereq instead of requireand with salt-ssh i don't have any problems.
But, i don't able to test if this is the correct replace (according to your CR) for salt-call command.

@vutny
Copy link
Contributor

vutny commented Mar 29, 2019

No worries @thomasrossetto !

Just update the PR with your new changes and I think we'd make it through.
Thank you for your efforts.

@aboe76 aboe76 requested a review from vutny April 3, 2019 18:36
Copy link
Contributor

@vutny vutny left a comment

Choose a reason for hiding this comment

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

Thanks for the update, @thomasrossetto !

I would like you to do some small clean up, and this would be good to go.

@@ -164,13 +164,12 @@ postgresql-pg_hba:
# Create the empty file before managing to overcome the limitation of check_cmd
- onlyif: test -f {{ pg_hba_path }} || touch {{ pg_hba_path }}
Copy link
Contributor

Choose a reason for hiding this comment

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

This is no longer needed since we are going to remove check_cmd parameter. Same applies for the pg_ident.

{%- endif %}
{%- else %}
- replace: False
{%- endif %}
- prereq:
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess we must wrap this with {%- if postgres.config_backup %} ... {%- endif %} statements, instead of onlyif and check_cmd, because no need to trigger backup if it was disabled.

@@ -214,6 +211,18 @@ postgresql-pg_ident:
- service: postgresql-running
{%- endif %}

backup_pg_ident:
Copy link
Contributor

Choose a reason for hiding this comment

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

Like above, we need the if statement here. These states also should be applied only when postgres.config_backup variable would contain any meaningful value.

@vutny
Copy link
Contributor

vutny commented Apr 19, 2019

@thomasrossetto Would you be able to finish this PR and address the comments?
Your changes are great, we just need to resolve the case where local config backup is explicitly disabled. This is long time legacy, and by removing it you will significantly improve the formula.
Thanks for your work and contributions here!

@myii
Copy link
Contributor

myii commented Apr 25, 2019

Good work @thomasrossetto! I've been working on getting the Travis-based Kitchen tests established for this formula but the fedora-28 instance was failing.

https://travis-ci.org/myii/postgres-formula/jobs/524280903#L1427:

                 ID: postgresql-pg_hba
           Function: file.managed
               Name: /var/lib/pgsql/data/pg_hba.conf
             Result: False
            Comment: check_cmd execution failed

Applied these commits and it's now working.

https://travis-ci.org/myii/postgres-formula/jobs/524291445#L1439:

                 ID: postgresql-pg_hba
           Function: file.managed
               Name: /var/lib/pgsql/data/pg_hba.conf
             Result: True
            Comment: File /var/lib/pgsql/data/pg_hba.conf updated

While this might not be what your intention was when you submitted this PR, it's a nice bonus.

@myii
Copy link
Contributor

myii commented Apr 25, 2019

@vutny After setting up the CI PR (#262), the fedora-28 test is now passing, even without this merge.

https://travis-ci.com/saltstack-formulas/postgres-formula/jobs/195597494#L1552:

                 ID: postgresql-pg_hba
           Function: file.managed
               Name: /var/lib/pgsql/data/pg_hba.conf
             Result: True
            Comment: File /var/lib/pgsql/data/pg_hba.conf updated

So no need to merge this PR prematurely, it seems.

@vutny
Copy link
Contributor

vutny commented Apr 26, 2019

Great, thank you @myii !

@noelmcloughlin
Copy link
Contributor

Thanks, @thomasrossetto @myii @vutny

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.

4 participants