Skip to content
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

Ensure db and db users created before validation #125

Merged
merged 1 commit into from
Jul 1, 2014

Conversation

rickerc
Copy link
Contributor

@rickerc rickerc commented Apr 2, 2014

Ensure that for PostgreSQL backends, the database validation functions
are not run until the initial database creation and user role creation
has been completed.

Closes-Bug: #1298605

Ensure that for PostgreSQL backends, the database validation functions
are not run until the initial database creation and user role creation
has been completed.

Closes-Bug: #1298605
@kbarber
Copy link
Contributor

kbarber commented Apr 8, 2014

@rickerc can you give a little more details about the reason behind this change?

@kbarber
Copy link
Contributor

kbarber commented Apr 10, 2014

@rickerc ping

@rickerc
Copy link
Contributor Author

rickerc commented Apr 10, 2014

without it, when using a Postgres backend the validation gets run before the db role is there, so the validation fails:

Debug: /Stage[main]/Puppetdb::Database::Postgresql/Postgresql::Server::Db[puppetdb]/Postgresql::Server::Database[puppetdb]/Exec[/usr/lib/postgresql/9.3/bin/createdb --owner='postgres' --template=template0 'puppetdb']: The container Postgresql::Server::Database[puppetdb] will propagate my refresh event
Debug: Executing '/usr/bin/psql -d postgres -t -c REVOKE CONNECT ON DATABASE "puppetdb" FROM public'
Notice: /Stage[main]/Puppetdb::Database::Postgresql/Postgresql::Server::Db[puppetdb]/Postgresql::Server::Database[puppetdb]/Postgresql_psql[REVOKE CONNECT ON DATABASE "puppetdb" FROM public]: Triggered 'refresh' from 1 events
Debug: /Stage[main]/Puppetdb::Server::Validate_db/Postgresql::Validate_db_connection[validate puppetdb postgres connection]/Exec[validate postgres connection for localhost/puppetdb]/unless: psql: FATAL: password authentication failed for user "puppetdb"
Debug: Executing 'echo 'Unable to connect to defined database using: /usr/bin/psql --tuples-only --quiet -h localhost -U puppetdb -p 5432 --dbname puppetdb ' && false'
Notice: /Stage[main]/Puppetdb::Server::Validate_db/Postgresql::Validate_db_connection[validate puppetdb postgres connection]/Exec[validate postgres connection for localhost/puppetdb]/returns: Unable to connect to defined database using: /usr/bin/psql --tuples-only --quiet -h localhost -U puppetdb -p 5432 --dbname puppetdb
Error: echo 'Unable to connect to defined database using: /usr/bin/psql --tuples-only --quiet -h localhost -U puppetdb -p 5432 --dbname puppetdb ' && false returned 1 instead of one of [0]
Error: /Stage[main]/Puppetdb::Server::Validate_db/Postgresql::Validate_db_connection[validate puppetdb postgres connection]/Exec[validate postgres connection for localhost/puppetdb]/returns: change from notrun to 0 failed: echo 'Unable to connect to defined database using: /usr/bin/psql --tuples-only --quiet -h localhost -U puppetdb -p 5432 --dbname puppetdb ' && false returned 1 instead of one of [0]

@kbarber
Copy link
Contributor

kbarber commented Apr 10, 2014

@rickerc we use this module for our own testing for PuppetDB proper, and we haven't seen such a setup issue yet.

Is there a specific test that is breaking that shows this problem? If not can we get it added?

Can you provide some sample manifest code and other setup details to reproduce?

@kbarber
Copy link
Contributor

kbarber commented Apr 14, 2014

@rickerc ping

@kbarber
Copy link
Contributor

kbarber commented Apr 17, 2014

No response from @rickerc, closing. Please re-open once you can provide the details (or tests) necessary to reproduce.

@kbarber kbarber closed this Apr 17, 2014
@lathiat
Copy link

lathiat commented May 27, 2014

This happens for me too. What does it for me:

class profile::puppetmaster {
include ::apache
class {'::puppetdb': }
class {'::puppetdb::master::config':
puppet_service_name => 'apache2',
}
class { '::puppet':
server => true,
server_reports => 'puppetdb',
server_external_nodes => '',
}
}

@rustyautopsy
Copy link

We have the same issue. This is how we currently use puppetdb...

class profile::puppetmaster::puppetdb {
include ::puppetdb
}

This fails with the same errors/issues as mentioned earlier.

We also tried the following, which shouldn't be needed since a before => is present in puppetdb::database::postgresql

class {'puppetdb::server':
...
require => Class['puppetdb::database::postgresql']
}

No luck.

Any ideas?

@tdb
Copy link

tdb commented Jun 30, 2014

Another "me too".

Notice: /Stage[main]/Puppetdb::Server::Validate_db/Postgresql::Validate_db_connection[validate puppetdb postgres connection]/Exec[validate postgres connection for localhost/puppetdb]/returns: Unable to connect to defined database using: /usr/bin/psql --tuples-only --quiet -h localhost -U puppetdb -p 5432 --dbname puppetdb
Error: echo 'Unable to connect to defined database using: /usr/bin/psql --tuples-only --quiet -h localhost -U puppetdb -p 5432 --dbname puppetdb ' && false returned 1 instead of one of [0]
Error: /Stage[main]/Puppetdb::Server::Validate_db/Postgresql::Validate_db_connection[validate puppetdb postgres connection]/Exec[validate postgres connection for localhost/puppetdb]/returns: change from notrun to 0 failed: echo 'Unable to connect to defined database using: /usr/bin/psql --tuples-only --quiet -h localhost -U puppetdb -p 5432 --dbname puppetdb ' && false returned 1 instead of one of [0]

Notice: /Stage[main]/Puppetdb::Database::Postgresql/Postgresql::Server::Db[puppetdb]/Postgresql::Server::Role[puppetdb]/Postgresql_psql[CREATE ROLE "puppetdb" ENCRYPTED PASSWORD 'xDyfygrgxnphey1jLutccjt2lwsmms' LOGIN NOCREATEROLE NOCREATEDB NOSUPERUSER  CONNECTION LIMIT -1]/command: command changed '' to 'CREATE ROLE "puppetdb" ENCRYPTED PASSWORD 'XXXXXX' LOGIN NOCREATEROLE NOCREATEDB NOSUPERUSER  CONNECTION LIMIT -1'
Notice: /Stage[main]/Puppetdb::Database::Postgresql/Postgresql::Server::Db[puppetdb]/Postgresql::Server::Database_grant[GRANT puppetdb - all - puppetdb]/Postgresql::Server::Grant[database:GRANT puppetdb - all - puppetdb]/Postgresql_psql[GRANT ALL ON DATABASE "puppetdb" TO "puppetdb"]/command: command changed '' to 'GRANT ALL ON DATABASE "puppetdb" TO "puppetdb"'

You can clearly see the validation is done before the role is created and the permissions set up. So it's just an ordering issue. @kbarber maybe in your case the order just happens to work out better?

The right fix would appear to be ensuring the database is fully set up before validation is done. Please reopen the issue.

@kbarber kbarber reopened this Jul 1, 2014
kbarber added a commit that referenced this pull request Jul 1, 2014
Ensure db and db users created before validation
@kbarber kbarber merged commit b80b921 into puppetlabs:master Jul 1, 2014
@danielkza
Copy link

Would it be possible to release a maintenance version containing this fix? Right now I'm trying to use the modules as present on Forge and it doesn't work at all, I had to resort to downloading the master tarball and installing from it.

@smortex smortex added the bugfix label Apr 18, 2024
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.

7 participants