Skip to content

(maint) Add read-only user. #330

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

Merged
merged 3 commits into from
Jun 22, 2021

Conversation

Filipovici-Andrei
Copy link
Contributor

@Filipovici-Andrei Filipovici-Andrei commented Jun 9, 2021

There used to be only one user (puppetdb) which was used for all operations on the database.
This PR adds a read only user in PostgreSQL which will be used only for queries.

@Filipovici-Andrei Filipovici-Andrei requested a review from a team June 9, 2021 15:30
@puppet-community-rangefinder
Copy link

puppetdb::database::postgresql is a class

that may have no external impact to Forge modules.

This module is declared in 33 of 576 indexed public Puppetfiles.


These results were generated with Rangefinder, a tool that helps predict the downstream impact of breaking changes to elements used in Puppet modules. You can run this on the command line to get a full report.

Exact matches are those that we can positively identify via namespace and the declaring modules' metadata. Non-namespaced items, such as Puppet 3.x functions, will always be reported as near matches only.

@Filipovici-Andrei Filipovici-Andrei force-pushed the (maint)_add_user branch 15 times, most recently from 9da226b to 9d6dc8f Compare June 14, 2021 14:10
@Filipovici-Andrei Filipovici-Andrei marked this pull request as ready for review June 15, 2021 08:33
@Filipovici-Andrei Filipovici-Andrei force-pushed the (maint)_add_user branch 11 times, most recently from ce40382 to f7b7923 Compare June 15, 2021 15:08
option is supported in PuppetDB >= 1.6.

#### `read_database_username`

The name of the read database user to connect as. Defaults to `puppetdb`. This
The name of the read database user to connect as. Defaults to `puppetdb-read`. This
Copy link

@BogdanIrimie BogdanIrimie Jun 22, 2021

Choose a reason for hiding this comment

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

Does this always default to puppetdb-read? If managed is set to false will it still default to puppetdb-read or will it default to database_username?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This always defaults to puppetdb-read

option is supported in PuppetDB >= 1.6.

#### `read_database_password`

The password for the read database user. Defaults to `puppetdb`. This option is
The password for the read database user. Defaults to `puppetdb-read`. This option is

Choose a reason for hiding this comment

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

Same as for username

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, this will also default to puppetdb-read as well.

@austb austb force-pushed the (maint)_add_user branch from 8767acf to c27ef55 Compare June 22, 2021 22:32
{
database_name: 'puppetdb',
read_database_username: 'puppetdb-read',
create_read_user_rule: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

I added the comma here to appease rubocop.

@austb austb merged commit cfdc6e2 into puppetlabs:master Jun 22, 2021
@Filipovici-Andrei Filipovici-Andrei deleted the (maint)_add_user branch June 23, 2021 08:17
@alexjfisher
Copy link
Contributor

FWIW, I think this should have been labelled as a breaking change, not just a feature. If you weren't managing postgresql with this module, the change in puppetdb configuration stops puppetdb from starting (my case).
If you were, then your database now gets a user with a non-strong default password?

alexjfisher added a commit to alexjfisher/puppetlabs-puppetdb that referenced this pull request Jul 2, 2021
puppetlabs#330 uses the
namespaced `postgresql::postgresql_password` function that wasn't
available until 6.5.0.

(Even before that PR, I doubt this module worked with
puppetlabs/postgresql 4.0.0 released in 2014).
@waipeng
Copy link
Contributor

waipeng commented Oct 6, 2021

I wonder if anyone is running into the following error?

Error: /Stage[main]/Puppetdb::Database::Postgresql/Puppetdb::Database::Read_only_user[puppetdb-read]/Puppetdb::Database::Default_read_grant[puppetdb grant read permission on new objects from puppetdb to puppetdb-read]/Postgresql_psql[grant default select permission for puppetdb-read]: Could not evaluate: Error evaluating 'unless' clause, returned pid 22961 exit 2: 'sh: 8: Syntax error: Unterminated quoted string

Looks like there are mismatch quotes in the code.

I've also opened up a ticket in puppet https://tickets.puppetlabs.com/browse/MODULES-11204, as "Issues" is not enabled for this repo in Github.

waipeng added a commit to waipeng/puppetlabs-puppetdb that referenced this pull request Sep 1, 2023
puppetdb in default config tries to create a read-only user, however
there is a bug[1] with the syntax to create a user.

Fix it with help from comments[2].

[1] puppetlabs#330 (comment)
[2] puppetlabs#339 (comment)
waipeng added a commit to waipeng/puppetlabs-puppetdb that referenced this pull request Sep 1, 2023
puppetdb in default config will create a read-only user, however there
is a bug[1] with the syntax to set the default read grant.

Fix it with help from comments[2].

[1] puppetlabs#330 (comment)
[2] puppetlabs#339 (comment)
nectar-gerrit pushed a commit to NeCTAR-RC/puppetlabs-puppetdb that referenced this pull request Sep 4, 2023
puppetdb in default config will create a read-only user, however there
is a bug[1] with the syntax to set the default read grant.

Fix it with help from comments[2].

[1] puppetlabs#330 (comment)
[2] puppetlabs#339 (comment)

Change-Id: Ifeb89602c40c21dab747536fe74dca4457215b26
nectar-gerrit pushed a commit to NeCTAR-RC/puppetlabs-puppetdb that referenced this pull request Sep 4, 2023
puppetdb in default config will create a read-only user, however there
is a bug[1] with the syntax to set the default read grant.

Fix it with help from comments[2].

[1] puppetlabs#330 (comment)
[2] puppetlabs#339 (comment)

Change-Id: Ifeb89602c40c21dab747536fe74dca4457215b26
waipeng added a commit to waipeng/puppetlabs-puppetdb that referenced this pull request Nov 14, 2023
puppetdb in default config will create a read-only user, however there
is a bug[1] with the syntax to set the default read grant.

Fix it with help from comments[2].

[1] puppetlabs#330 (comment)
[2] puppetlabs#339 (comment)

Co-authored-by: Romain Tartière <[email protected]>
Signed-off-by: Jake Yip <[email protected]>
waipeng added a commit to waipeng/puppetlabs-puppetdb that referenced this pull request Nov 14, 2023
puppetdb in default config will create a read-only user, however there
is a bug[1] with the syntax to set the default read grant.

Fix it with help from comments[2].

[1] puppetlabs#330 (comment)
[2] puppetlabs#339 (comment)

Co-authored-by: Romain Tartière <[email protected]>
Signed-off-by: Jake Yip <[email protected]>
waipeng added a commit to waipeng/puppetlabs-puppetdb that referenced this pull request Feb 3, 2024
puppetdb in default config will create a read-only user, however there
is a bug[1] with the syntax to set the default read grant.

Fix it with help from comments[2].

[1] puppetlabs#330 (comment)
[2] puppetlabs#339 (comment)

Co-authored-by: Romain Tartière <[email protected]>
Signed-off-by: Jake Yip <[email protected]>
waipeng added a commit to waipeng/puppetlabs-puppetdb that referenced this pull request Feb 5, 2024
puppetdb in default config will create a read-only user, however there
is a bug[1] with the syntax to set the default read grant.

Fix it with help from comments[2].

[1] puppetlabs#330 (comment)
[2] puppetlabs#339 (comment)

Co-authored-by: Romain Tartière <[email protected]>
Signed-off-by: Jake Yip <[email protected]>
waipeng added a commit to waipeng/puppetlabs-puppetdb that referenced this pull request Feb 6, 2024
puppetdb in default config will create a read-only user, however there
is a bug[1] with the syntax to set the default read grant.

Fix it with help from comments[2].

[1] puppetlabs#330 (comment)
[2] puppetlabs#339 (comment)

Co-authored-by: Romain Tartière <[email protected]>
Signed-off-by: Jake Yip <[email protected]>
waipeng added a commit to waipeng/puppetlabs-puppetdb that referenced this pull request Feb 10, 2024
puppetdb in default config will create a read-only user, however there
is a bug[1] with the syntax to set the default read grant.

Fix it with help from comments[2].

[1] puppetlabs#330 (comment)
[2] puppetlabs#339 (comment)

Co-authored-by: Romain Tartière <[email protected]>
Signed-off-by: Jake Yip <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants