Skip to content

Instantly share code, notes, and snippets.

@tknerr
Created November 25, 2012 10:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tknerr/4143033 to your computer and use it in GitHub Desktop.
Save tknerr/4143033 to your computer and use it in GitHub Desktop.
updated postgresql::client with workaround for COOK-1406 (compile from source)
#
# Cookbook Name:: postgresql
# Recipe:: client
#
# Author:: Joshua Timberman (<joshua@opscode.com>)
# Author:: Lamont Granquist (<lamont@opscode.com>)
# Copyright 2009-2011 Opscode, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
pg_packages = case node['platform']
when "ubuntu","debian"
%w{postgresql-client libpq-dev}
when "fedora","suse","amazon"
%w{postgresql-devel}
when "redhat","centos","scientific"
case
when node['platform_version'].to_f >= 6.0
%w{postgresql-devel}
else
[ "postgresql#{node['postgresql']['version'].split('.').join}-devel" ]
end
end
pg_packages.each do |pg_pack|
package pg_pack do
action :nothing
end.run_action(:install)
end
def is_omnibus?
Gem.bindir =~ %r{/opt/(opscode|chef)/}
end
def has_incompatible_openssl?
is_omnibus? && node['platform'] == "ubuntu" && node['platform_version'] == "12.04"
end
if has_incompatible_openssl?
package "build-essential" do
action :nothing
end.run_action(:install)
execute "compile postgres for omnibus openssl issue (might take a while)" do
command <<-EOH
cd /tmp
apt-get build-dep -y --force-yes postgresql
wget http://ftp.postgresql.org/pub/source/v9.1.6/postgresql-9.1.6.tar.gz
tar -zxvf postgresql-9.1.6.tar.gz
cd postgresql-9.1.6
export MAJOR_VER=9.1
./configure \
--prefix=/opt/chef/embedded \
--mandir=/opt/chef/embedded/share/postgresql/${MAJOR_VER}/man \
--docdir=/opt/chef/embedded/share/doc/postgresql-doc-${MAJOR_VER} \
--sysconfdir=/etc/postgresql-common \
--datarootdir=/opt/chef/embedded/share/ \
--datadir=/opt/chef/embedded/share/postgresql/${MAJOR_VER} \
--bindir=/opt/chef/embedded/lib/postgresql/${MAJOR_VER}/bin \
--libdir=/opt/chef/embedded/lib/ \
--libexecdir=/opt/chef/embedded/lib/postgresql/ \
--includedir=/opt/chef/embedded/include/postgresql/ \
--enable-nls \
--enable-integer-datetimes \
--enable-thread-safety \
--enable-debug \
--with-gnu-ld \
--with-pgport=5432 \
--with-openssl \
--with-libedit-preferred \
--with-includes=/opt/chef/embedded/include \
--with-libs=/opt/chef/embedded/lib
make
sudo make install
EOH
creates "/opt/chef/embedded/lib/libpq.so"
action :nothing
end.run_action(:run)
execute "install pg gem with omnibus-compatible postgresql libs" do
command "sudo /opt/chef/embedded/bin/gem install pg -- --with-pg-config=/opt/chef/embedded/lib/postgresql/9.1/bin/pg_config"
action :nothing
not_if "/opt/chef/embedded/bin/gem which pg"
end.run_action(:run)
else
chef_gem "pg" do
action :nothing
end.run_action(:install)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment