Looks like it works now, in case anyone needs it or want to expand the doc,
here is the full process:
Install (and start) the required packages
yum install postgresql-server
service postgresql initdb
service postgresql start
chkconfig postgresql on
yum install foreman-postgresql
Set up the initial foreman DB and user:
sudo -u postgres psql template1
template1=# alter user postgres with encrypted password 'password';
template1=# create database foreman;
template1=# create user foreman with encrypted password 'password';
template1=# grant all privileges on database foreman to foreman;
Drop the old puppet tables from sqlite:
sqlite3 /var/lib/foreman/db/production.sqlite3
> drop table resources;
> drop table puppet_tags;
> drop table resource_tags;
> drop table source_files;
> drop table param_names;
> drop table param_values;
> drop table inventory_nodes;
> drop table inventory_facts;
Configure foreman database access:
vi /etc/foreman/database.yml
development:
adapter: postgresql
database: foreman
username: foreman
password: password
host: localhost
test:
adapter: sqlite3
database: db/test.sqlite3
pool: 5
timeout: 5000
production:
adapter: sqlite3
database: db/production.sqlite3
pool: 5
timeout: 5000
Configure postgresql authentication with encrypted passwords:
vi /var/lib/pgsql/data/pg_hba.conf
"local" is for Unix domain socket connections only
local all all md5
IPv4 local connections:
host all all 127.0.0.1/32 md5
IPv6 local connections:
host all all ::1/128 md5
Now run the commands as per the documentation:
sudo -u postgres psql -c 'ALTER USER foreman WITH SUPERUSER'
foreman-rake db:migrate RAILS_ENV=production
foreman-rake db:migrate RAILS_ENV=development
foreman-rake db:convert:prod2dev
sudo -u postgres psql -c 'ALTER USER foreman WITH NOSUPERUSER'
cat <<EOF > reset.sql
SELECT 'SELECT SETVAL(' ||quote_literal(S.relname)|| ', MAX('
>>quote_ident(C.attname)|| ') ) FROM ' ||quote_ident(T.relname)|| ';'
FROM pg_class AS S, pg_depend AS D, pg_class AS T, pg_attribute AS C
WHERE S.relkind = 'S'
AND S.oid = D.objid
AND D.refobjid = T.oid
AND D.refobjid = C.attrelid
AND D.refobjsubid = C.attnum
ORDER BY S.relname;
EOF
psql -U postgres -Atq -f reset.sql -o temp foreman
psql -U postgres -f temp foreman
rm temp reset.sql
Finally, swap the 'production' and 'development'
vi /etc/foreman/database.yml
production:
adapter: postgresql
database: foreman
username: foreman
password: password
host: localhost
test:
adapter: sqlite3
database: db/test.sqlite3
pool: 5
timeout: 5000
development:
adapter: sqlite3
database: db/production.sqlite3
pool: 5
timeout: 5000