Skip to content

Resolve dependencies to the databases automatically #963

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

Closed
wants to merge 4 commits into from

Conversation

hasegeli
Copy link
Contributor

@hasegeli hasegeli commented Mar 1, 2018

No description provided.

@hasegeli hasegeli force-pushed the autobefore branch 2 times, most recently from 72b65fb to 053a555 Compare March 1, 2018 18:16
@david22swan
Copy link
Member

@hasegeli Your changes are currently causing failures in the grant_spec acceptance test's on lines 98 and 110. Please fix this before it can be merged.

@hasegeli hasegeli force-pushed the autobefore branch 2 times, most recently from ab56e5e to 795180e Compare March 2, 2018 15:39
@hasegeli
Copy link
Contributor Author

hasegeli commented Mar 6, 2018

Could you please retrigger the tests?

@david22swan david22swan closed this Mar 6, 2018
@david22swan david22swan reopened this Mar 6, 2018
@david22swan
Copy link
Member

@hasegeli I've closed and opened the PR. The test's should show fine now.

@hasegeli hasegeli force-pushed the autobefore branch 2 times, most recently from 5c1c51e to 6ebd78c Compare March 7, 2018 16:39
@ekohl
Copy link
Collaborator

ekohl commented Mar 28, 2018

In #950 I also do a lot of dependency chaining like this. Could anyone have a look at what would be the better approach?

Copy link
Contributor

@hunner hunner left a comment

Choose a reason for hiding this comment

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

I think this and #950 are both complementary.

@@ -4,7 +4,6 @@
$password_hash = false,
$createdb = false,
$createrole = false,
$db = $postgresql::server::default_database,
Copy link
Contributor

@hunner hunner Mar 29, 2018

Choose a reason for hiding this comment

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

This parameter is considered public API and removing it would be breaking, even if it doesn't actually do anything. If the db param is not needed then we could just make it unused and deprecated it, and remove it later.

Does the database specified not affect the ALTER ROLE commands below? Are roles always defined globally and not db-specific?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes roles are always global on Postgres. This option was also not documented. I find it hard to believe anyone would search and find the argument that does nothing. Should we still keep it and emit a warning()?

Copy link
Contributor

@hunner hunner Apr 4, 2018

Choose a reason for hiding this comment

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

Interesting that it was not documented. Yes, I think it should still be kept and just emit a warning and do nothing. It has been there ever since postgresql::server::role was created in 2013 and even before that for postgresql::role. And it's in the acceptance tests. I'm sure there are people using it for years :.

@ekohl
Copy link
Collaborator

ekohl commented Apr 3, 2018

This needs a rebase now.

@hasegeli
Copy link
Contributor Author

hasegeli commented Apr 4, 2018

Have you seen the comment

+  # XXX: We should probably do everything in this class before.  Postgresql_psql resource could
+  # specify this better, but currently it is impossible to use "autorequire" against custom
+  # resources.  We can improve this when a better way is available.

Do you know how to implement it inside Postgresql_psql rather than postgresql::server::database. I cannot read Ruby code. I might be missing something.

@ekohl
Copy link
Collaborator

ekohl commented Apr 4, 2018

Do you know how to implement it inside Postgresql_psql rather than postgresql::server::database. I cannot read Ruby code. I might be missing something.

I think I implemented this in d69ff1e but please verify this.

@hasegeli
Copy link
Contributor Author

hasegeli commented Apr 4, 2018

Yes, we need the same but against a resource not a class. Do you know how to do it? This is how its done on Puppet:

Postgresql_psql["CREATE DATABASE \"${dbname}\""] -> Postgresql_psql <| db == $dbname |>

@hunner
Copy link
Contributor

hunner commented Apr 4, 2018

Postgresql_psql["CREATE DATABASE \"${dbname}\""] -> Postgresql_psql <| db == $dbname |>

I think this would be in autorequire like:

autorequire(:postgresql_psql) do
  ["CREATE DATABASE #{self[:db]}"]
end

@hasegeli
Copy link
Contributor Author

hasegeli commented Apr 5, 2018

This would be the same as the current coding. Although it would be better if we could rely on the whole postgresql::server::database resource. Can we make something like the following work:

autorequire(:postgresql::server::db) do
  [#{self[:db]}]
end

hasegeli added 4 commits April 6, 2018 19:24
This option doesn't make sense, because roles are not specific to
databases on PostgreSQL.  It was not documented on the README,
so I don't see value in making this backwards compatible.
@mattman578
Copy link

Hello, we have been using your submodle for a while and we are currently having an issue
when I run puppet parser validate on server.pp I get the following error message
Error: Could not parse for environment production: Syntax error at 'Hash'; expected ')' at /home/mayres/git/puppetlabs-postgresql/manifests/server.pp:59
Can you please point me in the correct direction to fix ?

@david22swan
Copy link
Member

@hasegeli I am know closing this as you had previously mentioned in another PR that you had finished working with Puppet. I would like to once again state how sorry I am to hear that, and hope to one day hear from you again in the future.

@david22swan david22swan closed this Nov 8, 2018
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.

5 participants