On 17/05/13 10:55, Daniel DeLeo wrote:
"
type="cite">
On Thursday, May 16, 2013 at 5:39 PM,
Jeffrey Jones wrote:
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:
1) 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: https://github.com/opscode-cookbooks/postgresql/pull/59
Woot, thanks. Did you file a ticket on
http://tickets.opscode.com/secure/Dashboard.jspa ? I know it
feels redundant, but we use jira to keep track of what goes in
each release and we got heavily invested in Jira before github
had any features that met our needs. Creating a ticket
on tickets.opscode.com and setting to "fix provided" with a link
to your pull request will ensure your contribution comes up
during code review meetings (these are held on G+ hangouts if
you're interested in participating).
I created a ticket
[COOK-2954] But I could not figure out how to set the "fix provided"
status so I just added a comment with the link. If someone could
give me a hint (or set it themselves) then that would be grand.
Code review sounds interesting, not sure about timezone issues (I am
in Japan) and G+ registration requirements. Is there a page
somewhere with information on when these are held?
"
type="cite">
2) 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.
The code there is forcing the packages to get installed
during the cookbook compile phase so the C library deps of the
pg gem are available when the gem gets installed, which is
itself required to be available early for database resources to
work. It may be possible to rework the cookbook to avoid this
hackery, I'm not too familiar with it so I can't say.
Ok, that makes sense'ish but it seems that it is trying to install
the packages in the compile phase but not setting up the pgdg
repository, this is fine when using standard PostgreSQL 8.4 but
PostgreSQL 9.2 needs the pgdg repository setup. This sounds like an
edge-case bug but I would be very hesitant to make any changes since
I do not really understand what is going on there. If I would like
someone to look at it should I make a ticket?
"
type="cite">
3) 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.
4) 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).
IIRC, in some cases there have been conflicts between the
OpenSSL included with the omnibus package (that is linked by the
embedded ruby) and the one installed from packages. That code is
a bunch of hackery to workaround the issue. Again, I'm not
personally familiar with the constraints on the solution.
Yea, I did a bit of reading but again I cannot really follow the
hackery. All I can say is that it failed to install no matter what I
tried with chef_gem, I cannot remember if I tried it with the
default packages (must give that a go) or if it is only failing
because I am using PostgreSQL 9.2. I need to check that but time is
a bit tight. The bash workaround was all I could come up with that
worked.
"
type="cite">
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
Hope you find that a bit helpful.
--
Daniel DeLeo
Many thanks, very useful explanations, I need to do some checking to
see if the problems are a result of my not using the default CentOS
version or not.
Cheers
Jeff
|