separating puppetdb and postgresql

261 views
Skip to first unread message

Christopher Wood

unread,
Apr 24, 2017, 5:08:37 PM4/24/17
to puppet...@googlegroups.com
I am attempting to use the Puppet puppetdb and postgresql modules from the forge to have postgresql live on a separate server from puppetdb itself. It's not going brilliantly as I'm not understanding how to inform the postgresql module about what version of postgresql is in use for a versioncmp in postgresql::server::role.

My questions to other people who have put postgresql on another host, or read puppet dsl better than me, would be these:

1) which classes and params did you declare in the profile to get over this hump?
2) am I able to get $connect_settings fed into postgresql::server::role somehow?

Exhibit A, mildly tweaked for privacy:

Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Evaluation Error: Error while evaluating a Resource Statement, Evaluation Error: Error while evaluating a Function Call, 'versioncmp' parameter 'a' expects a String value, got Undef at /etc/puppetlabs/code/environments/puppetmasters_test/modules/postgresql/manifests/server/role.pp:95:6 at /etc/puppetlabs/code/environments/puppetmasters_test/modules/postgresql/manifests/server/db.pp:30 on node temphost1.me.com

The puppetlabs-puppetdb module is at 5.1.2 (b641845), and the puppetlabs-postgresql module is at 4.9.0 (3021eb3).

The puppetdb module is currently in the profile like so (still working out all the things I need here):

class { '::puppetdb':
certificate_whitelist => [
'cwood',
'some.more',
'etc.',
],
conn_keep_alive => '5',
database_host => 'db.me.com',
java_args => {
'-Xmx' => '2g',
'-Xms' => '512m',
},
jdbc_ssl_properties => '?ssl=true&sslfactory=org.postgresql.ssl.jdbc4.LibPQFactory&sslmode=verify-full&sslrootcert=/etc/puppetlabs/puppetdb/ssl/ca.pem',
manage_dbserver => false,
manage_package_repo => false,
node_purge_ttl => '1d',
node_ttl => '14d',
postgres_version => '9.5',
}


If I'm reading this correctly the puppetdb::database::postgresql class is declared in the puppetdb class. I am not managing postgresql itself on this server (manage_dbserver above) so the postgresql::server::db (defined type) declares (a) postgresql::server::role (defined type) without declaring the postgresql::server class.

https://github.com/puppetlabs/puppetlabs-puppetdb/blob/5.1.2/manifests/init.pp
https://github.com/puppetlabs/puppetlabs-puppetdb/blob/5.1.2/manifests/database/postgresql.pp
https://github.com/puppetlabs/puppetlabs-postgresql/blob/4.9.0/manifests/server/role.pp
https://github.com/puppetlabs/puppetlabs-postgresql/blob/4.9.0/manifests/server/db.pp

The catch appears to be that postgresql::server::role uses $connect_settings as a parameter, but it is declared as such in postgresql::server::db:

if ! defined(Postgresql::Server::Role[$user]) {
postgresql::server::role { $user:
password_hash => $password,
before => Postgresql::Server::Database[$dbname],
}
}

However the version is taken from this in role.pp:

# If possible use the version of the remote database, otherwise
# fallback to our local DB version
if $connect_settings != undef and has_key( $connect_settings, 'DBVERSION') {
$version = $connect_settings['DBVERSION']
} else {
$version = $postgresql::server::_version
}

Neither of the $version assignments there work so $version ends up null and this check on line 95 of role.pp produces the error above:

if(versioncmp($version, '9.1') >= 0) {

This is the wall upon which my head is currently beating, if anybody has any hints.

Angel L. Mateo

unread,
Apr 25, 2017, 1:52:40 AM4/25/17
to puppet...@googlegroups.com
Hello,

I have this same configuration working without any problem.

El 24/04/17 a las 23:08, Christopher Wood escribió:
> I am attempting to use the Puppet puppetdb and postgresql modules from the forge to have postgresql live on a separate server from puppetdb itself. It's not going brilliantly as I'm not understanding how to inform the postgresql module about what version of postgresql is in use for a versioncmp in postgresql::server::role.
>
> My questions to other people who have put postgresql on another host, or read puppet dsl better than me, would be these:
>
> 1) which classes and params did you declare in the profile to get over this hump?

In my puppetdb server profile I have:

class profile::puppetdb::server {

include ::puppetdb::globals
include ::puppetdb::server
...
}

I don't include any other puppetdb class.

And my config (that I have on hiera) I have:
puppetdb::server::listen_address: '0.0.0.0'
puppetdb::server::listen_port: 8080
puppetdb::server::disable_ssl: true
puppetdb::server::database: postgres
puppetdb::server::database_host: 'postgres.mydomain.com'
puppetdb::server::database_username: 'puppetdb'
puppetdb::server::database_name: 'puppetdb'
puppetdb::server::database_password: 'mypassword'
puppetdb::server::node_ttl: '15d'
puppetdb::server::node_purge_ttl: '15d'
puppetdb::server::java_args:
'-Xmx': '4g'

I don't pass any other parameter to puppetdb classes

> 2) am I able to get $connect_settings fed into postgresql::server::role somehow?
>
I don't explicitly deal with postgresql::server::role at all, neither
in puppetdb profile neither in postgresql server profile.

--
Angel L. Mateo Martínez
Sección de Telemática
Área de Tecnologías de la Información
y las Comunicaciones Aplicadas (ATICA)
http://www.um.es/atica
Tfo: 868889150
Fax: 868888337

Christopher Wood

unread,
Apr 25, 2017, 4:58:31 PM4/25/17
to puppet...@googlegroups.com
(inline)

On Tue, Apr 25, 2017 at 07:52:19AM +0200, Angel L. Mateo wrote:
> Hello,
>
> I have this same configuration working without any problem.
>
> El 24/04/17 a las 23:08, Christopher Wood escribió:
> >I am attempting to use the Puppet puppetdb and postgresql modules from the forge to have postgresql live on a separate server from puppetdb itself. It's not going brilliantly as I'm not understanding how to inform the postgresql module about what version of postgresql is in use for a versioncmp in postgresql::server::role.
> >
> >My questions to other people who have put postgresql on another host, or read puppet dsl better than me, would be these:
> >
> >1) which classes and params did you declare in the profile to get over this hump?
>
> In my puppetdb server profile I have:
>
> class profile::puppetdb::server {
>
> include ::puppetdb::globals
> include ::puppetdb::server
> ...

I facepalmed so hard at how I missed just declaring puppetdb::server directly. I got it working as you've shown, using puppetdb::server on the puppetdb node. I also had to declare puppetdb::database::postgresql on the postgresql node to ensure the database was there in the first place.

I tested an agent run with a scratch puppetserver node and I was able to do a successful agent run and then retrieve the node entry via http://localhost:8080/pdb/query/v4/nodes on the no-postgresql puppetdb node.

Thank you, very much appreciated!
> --
> You received this message because you are subscribed to the Google Groups "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/eefcaaa8-461f-9abd-2f19-f205fe603904%40um.es.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages