example42/puppet-postgresql

postgresql::dbcreate does not include postgresql

Closed this issue · 0 comments

I think the title for this is what the problem is. Apparently when evaluating exec resources, the environment variables USER, HOME and such aren't changed. This is what I think is causing this on my debian system:

Notice: /Stage[main]//Postgresql::Dbcreate[puppetdb]/Exec[role_puppetdb]/returns: psql: FATAL: role "root" does not exist
Error: echo "create role puppet nosuperuser nocreatedb nocreaterole noinherit nologin ; alter role puppet nosuperuser nocreatedb nocreaterole noinherit login encrypted password ''; grant puppetdb to puppet; create database puppetdb with OWNER=puppet TEMPLATE=template1 ENCODING='SQL_ASCII' LC_COLLATE='C' LC_CTYPE='C';" | /usr/bin/psql returned 2 instead of one of [0]
Error: /Stage[main]//Postgresql::Dbcreate[puppetdb]/Exec[role_puppetdb]/returns: change from notrun to 0 failed: echo "create role puppet nosuperuser nocreatedb nocreaterole noinherit nologin ; alter role puppet nosuperuser nocreatedb nocreaterole noinherit login encrypted password ''; grant puppetdb to puppet; create database puppetdb with OWNER=puppet TEMPLATE=template1 ENCODING='SQL_ASCII' LC_COLLATE='C' LC_CTYPE='C';" | /usr/bin/psql returned 2 instead of one of [0]

This should be running as postgres, but acts as though root is running it.

Edit: so this actually seems to be much easier than I thought. I missed this line in the puppet output before:

Warning: Scope(Postgresql::Dbcreate[puppetdb]): Could not look up qualified variable 'postgresql::process_user'; class postgresql has not been evaluated
So, we just need to include postgresql so that the variable can be evaluated first.