Hello all,
I have been messing around with Chef this week with a view to using it
to manage our Linux servers.
Generally things have been going well but I have run into a few problems
which I would like to ask more experienced chef'ers (Is there a proper
term for chef users?) about.
My goal is to install PostgreSQL 9.2 on CentOS 6.4. I wish to use the
"Database" cookbook to manage parts of the database therefore I need to
install the pg gem in chef. To this end I have the following .json file
and "master" cookbook recipe: https://gist.github.com/rurounijones/5596193
After much trial and tribulation I have managed to get PostgreSQL
installed BUT I have had to modify various recipes in the PostgreSQL
cookbook which seems...strange since I cannot believe I am the first
person who has tried the above.
Therefore I would like to ask if anyone can comment on the following and
let me know if I am missing something:
- PostgreSQL 9.2 on CentOS 6.4
As far as I can tell, using opscode's cookbook it is impossible to
install anything other than PostgreSQL 8.4 on CentOS >= 6.0 without
having t modify lots of things like package names, service names etc. I
have submitted a pull request regarding this:
- postgresql::ruby recipe
There appears to be a redundant chunk of code in the postgresql::ruby
recipe at
https://github.com/opscode-cookbooks/postgresql/blob/master/recipes/ruby.rb#L33
which was causing me problems. The line in question installs the client
packages but in the line right before it it includes the
postgresl::client recipe which... installs the client packages. I had
various problems with this chunk of code as it appeared to be running
before the postgresql::client code which resulted in it trying to
install the packages before the pgdg repository had been enabled.
Removing the package installation code from this file solved the issue.
- No libpqxx-devel
On all CentOS systems I have ever set-up with ruby and the pg gem I have
needed to install the libpqxx-devel library. However I can see no
mention of this package in any of the PostgreSQL chef scripts, I am
therefore puzzled how this has worked up until now, in my copy of the
cookbook I added this to the client packages.
- Installing the pg gem itself.
In relation to the above, on all CentOS systems I have ever used with
the libpqxx-devel library I have had to include the pg bin into the PATH
so that, during installation, the pg gem can find the pg_config binary.
The pg gem installation code in the
https://github.com/opscode-cookbooks/postgresql/blob/master/recipes/ruby.rb
is pretty complex, and do be honest, I am not entirely sure what it is
doing. However, on a CentOS 6.4 install I was never able to get this
working (I am afraid I did not save the error message, apologies). What
I did instead was replace the chef_gem method
(https://github.com/opscode-cookbooks/postgresql/blob/master/recipes/ruby.rb#L40)
with
the following:
bash 'install_chef_pg_gem' do
code <<-EOH
PATH=$PATH:/usr/pgsql-9.2/bin /opt/chef/embedded/bin/gem install pg
EOH
end
It may not be pretty but it works for me (caveat emptor).
Now as I said before, with the above modifications, I have managed to
install PostgreSQL, setup database management etc. so I am quite happy
but I am shocked that I had to make the above changes, it rather implies
that I am "doing it wrong" or misunderstanding something.
What I would like is for a Chef'er to have a look at my findings and
tell me if I am doing things wrong. If it IS possible to install
PostgreSQL 9.2 on CentOS 6.4 with the pg gem installed into chef without
having to modify the postgresql cookbook as I have done, would it be
possible for some nice person to put up a sample of how it would be done?
(If you have Vagrant then I am using the following box:
http://developer.nrel.gov/downloads/vagrant-boxes/CentOS-6.4-x86_64-v20130309.box
)
Cheers,
Jeff