-
Notifications
You must be signed in to change notification settings - Fork 610
Description
I'm using Oracle Enterprise Linux (RHEL) 6.4, Postgres 8.4.13, and puppet 3.2.4
I have postgresql::globals::datadir set to /var/opt/pgsql/data, however this causes errors during the puppet run.
The RHEL postgresql package creates the postgres user with a home directory of /var/lib/pgsql.
The first error I get during the puppet run is permission denied:
Notice: /Stage[main]/Postgresql::Server::Initdb/Exec[postgresql_initdb]/returns: creating directory /var/opt/pgsql/data ... initdb: could not create directory "/var/opt/pgsql": Permission denied
Error: /usr/bin/initdb --encoding '' --pgdata '/var/opt/pgsql/data' returned 1 instead of one of [0]
Error: /Stage[main]/Postgresql::Server::Initdb/Exec[postgresql_initdb]/returns: change from notrun to 0 failed: /usr/bin/initdb --encoding '' --pgdata '/var/opt/pgsql/data' returned 1 instead of one of [0]
This is because initdb is run by the postgres user and /var/opt is owned by root. To fix this, I changed the home directory of the postgres user to /var/opt/pgsql, and the directory was then created by puppet.
However then puppet tried to start the database, and I got another error:
Info: Class[Postgresql::Server::Service]: Scheduling refresh of Postgresql::Validate_db_connection[validate_service_is_running]
Error: Could not start Service[postgresqld]: Execution of '/sbin/service postgresql start' returned 4:
Error: /Stage[main]/Postgresql::Server::Service/Service[postgresqld]/ensure: change from stopped to running failed: Could not start Service[postgresqld]: Execution of '/sbin/service postgresql start' returned 4:
Running the startup manually showed what the error 4 means:
root@hostname # service postgresql start
touch: cannot touch `/var/lib/pgsql/pgstartup.log': No such file or directory
This was because RHEL hardcodes /var/lib/pgsql/data and /var/lib/pgsql/pgstartup.log as defaults for it's PGDATA and PGLOG variables in the postgresql startup script. The "RHEL way" is to put any overrides to these defaults in the /etc/sysconfig/pgsql/postgresql file.
So I'd like to request the following for the module:
- The module should manage the /etc/sysconfig/pgsql/postgresql file on redhat servers. Information about what goes in that file can be found at http://wiki.postgresql.org/wiki/PostgreSQL_on_RedHat_Linux
- If $datadir is something other than the default /var/lib/pgsql/data, have puppet create the directory and any needed parent directories and give them the appropriate permissions (It's IMO better than changing the postgres user's home directory)