Skip to content

Commit

Permalink
Merge branch 'track_upstream'
Browse files Browse the repository at this point in the history
  • Loading branch information
davidc-donorschoose committed Feb 4, 2013
2 parents 49c094d + 7fbfa99 commit 1968bc7
Show file tree
Hide file tree
Showing 4 changed files with 318 additions and 0 deletions.
25 changes: 25 additions & 0 deletions README.md
Expand Up @@ -53,6 +53,10 @@ The following attributes are set based on the platform, see the
by Martin Pitti, which contains newer versions of PostgreSQL. See
__Recipes__ "`ppa_pitti_postgresql`" below for more information.

* `node['postgresql']['enable_pgdg_yum']` - Whether to enable the yum repo
by the PostgreSQL Global Development Group, which contains newer versions
of PostgreSQL.

The following attributes are generated in
`recipe[postgresql::server]`.

Expand Down Expand Up @@ -197,6 +201,27 @@ attribute is true. Also set the
use from this repository, and set the `node['postgresql']['version']`
attribute to the version to use (e.g., "9.2").

yum\_pgdg\_postgresql
---------------------

Enables the PostgreSQL Global Development Group yum repository
maintained by Devrim Gündüz for updated PostgreSQL packages.
(The PGDG is the groups that develops PostgreSQL.)
Automatically included if the `node['postgresql']['enable_pgdg_yum']`
attribute is true. Also use `override_attributes` to set a number of
values that will need to have embedded version numbers. For example:

node['postgresql']['enable_pgdg_yum'] = true
node['postgresql']['version'] = "9.2"
node['postgresql']['dir'] = "/var/lib/pgsql/9.2/data"
node['postgresql']['client']['packages'] = ["postgresql92"]
node['postgresql']['server']['packages'] = ["postgresql92-server"]
node['postgresql']['server']['service_name'] = "postgresql-9.2"
node['postgresql']['contrib']['packages'] = ["postgresql92-contrib"]

You may set `node['postgresql']['pgdg']['repo_rpm_url']` attributes
to pick up recent [PGDG repo packages](http://yum.postgresql.org/repopackages.php).

Resources/Providers
===================

Expand Down
229 changes: 229 additions & 0 deletions attributes/default.rb
Expand Up @@ -182,3 +182,232 @@
default['postgresql']['password'] = Hash.new

default['postgresql']['enable_pitti_ppa'] = false
default['postgresql']['enable_pgdg_yum'] = false

# The PostgreSQL RPM Building Project built repository RPMs for easy
# access to the PGDG yum repositories. Links to RPMs for installation
# on the supported version/platform combinations are listed at
# http://yum.postgresql.org/repopackages.php, and the links for
# PostgreSQL 8.4, 9.0, 9.1 and 9.2 (from 2013-01-15) are captured below.
#
# The correct RPM for installing /etc/yum.repos.d is based on:
# * the attribute configuring the desired Postgres Software:
# node['postgresql']['version'] e.g., "9.1"
# * the chef ohai description of the target Operating System:
# node['platform'] e.g., "centos"
# node['platform_version'] e.g., "5.7", truncated as "5"
# node['kernel']['machine'] e.g., "i386" or "x86_64"
default['postgresql']['pgdg']['repo_rpm_url'] = {
"9.2" => {
"centos" => {
"6" => {
"i386" => "http://yum.postgresql.org/9.2/redhat/rhel-6-i386/pgdg-centos92-9.2-6.noarch.rpm",
"x86_64" => "http://yum.postgresql.org/9.2/redhat/rhel-6-x86_64/pgdg-centos92-9.2-6.noarch.rpm"
},
"5" => {
"i386" => "http://yum.postgresql.org/9.2/redhat/rhel-5-i386/pgdg-centos92-9.2-6.noarch.rpm",
"x86_64" => "http://yum.postgresql.org/9.2/redhat/rhel-5-x86_64/pgdg-centos92-9.2-6.noarch.rpm"
}
},
"redhat" => {
"6" => {
"i386" => "http://yum.postgresql.org/9.2/redhat/rhel-6-i386/pgdg-redhat92-9.2-7.noarch.rpm",
"x86_64" => "http://yum.postgresql.org/9.2/redhat/rhel-6-x86_64/pgdg-redhat92-9.2-7.noarch.rpm"
},
"5" => {
"i386" => "http://yum.postgresql.org/9.2/redhat/rhel-5-i386/pgdg-redhat92-9.2-7.noarch.rpm",
"x86_64" => "http://yum.postgresql.org/9.2/redhat/rhel-5-x86_64/pgdg-redhat92-9.2-7.noarch.rpm"
}
},
"scientific" => {
"6" => {
"i386" => "http://yum.postgresql.org/9.2/redhat/rhel-6-i386/pgdg-sl92-9.2-8.noarch.rpm",
"x86_64" => "http://yum.postgresql.org/9.2/redhat/rhel-6-x86_64/pgdg-sl92-9.2-8.noarch.rpm"
},
"5" => {
"i386" => "http://yum.postgresql.org/9.2/redhat/rhel-5-i386/pgdg-sl92-9.2-8.noarch.rpm",
"x86_64" => "http://yum.postgresql.org/9.2/redhat/rhel-5-x86_64/pgdg-sl92-9.2-8.noarch.rpm"
}
},
"fedora" => {
"17" => {
"x86_64" => "http://yum.postgresql.org/9.2/fedora/fedora-17-x86_64/pgdg-fedora92-9.2-5.noarch.rpm"
},
"16" => {
"i386" => "http://yum.postgresql.org/9.2/fedora/fedora-16-i386/pgdg-fedora92-9.2-5.noarch.rpm",
"x86_64" => "http://yum.postgresql.org/9.2/fedora/fedora-16-x86_64/pgdg-fedora92-9.2-5.noarch.rpm"
},
"15" => {
"i386" => "http://yum.postgresql.org/9.2/fedora/fedora-15-i386/pgdg-fedora92-9.2-5.noarch.rpm",
"x86_64" => "http://yum.postgresql.org/9.2/fedora/fedora-15-x86_64/pgdg-fedora92-9.2-5.noarch.rpm"
}
}
},
"9.1" => {
"centos" => {
"6" => {
"i386" => "http://yum.postgresql.org/9.1/redhat/rhel-6-i386/pgdg-centos91-9.1-4.noarch.rpm",
"x86_64" => "http://yum.postgresql.org/9.1/redhat/rhel-5-x86_64/pgdg-centos91-9.1-4.noarch.rpm"
},
"5" => {
"i386" => "http://yum.postgresql.org/9.1/redhat/rhel-5-i386/pgdg-centos91-9.1-4.noarch.rpm",
"x86_64" => "http://yum.postgresql.org/9.1/redhat/rhel-5-x86_64/pgdg-centos91-9.1-4.noarch.rpm"
},
"4" => {
"i386" => "http://yum.postgresql.org/9.1/redhat/rhel-4-i386/pgdg-centos91-9.1-4.noarch.rpm",
"x86_64" => "http://yum.postgresql.org/9.1/redhat/rhel-4-x86_64/pgdg-centos91-9.1-4.noarch.rpm"
}
},
"redhat" => {
"6" => {
"i386" => "http://yum.postgresql.org/9.1/redhat/rhel-6-i386/pgdg-redhat91-9.1-5.noarch.rpm",
"x86_64" => "http://yum.postgresql.org/9.1/redhat/rhel-6-x86_64/pgdg-redhat91-9.1-5.noarch.rpm"
},
"5" => {
"i386" => "http://yum.postgresql.org/9.1/redhat/rhel-5-i386/pgdg-redhat91-9.1-5.noarch.rpm",
"x86_64" => "http://yum.postgresql.org/9.1/redhat/rhel-5-x86_64/pgdg-redhat91-9.1-5.noarch.rpm"
},
"4" => {
"i386" => "http://yum.postgresql.org/9.1/redhat/rhel-4-i386/pgdg-redhat-9.1-4.noarch.rpm",
"x86_64" => "http://yum.postgresql.org/9.1/redhat/rhel-4-x86_64/pgdg-redhat-9.1-4.noarch.rpm"
}
},
"scientific" => {
"6" => {
"i386" => "http://yum.postgresql.org/9.1/redhat/rhel-6-i386/pgdg-sl91-9.1-6.noarch.rpm",
"x86_64" => "http://yum.postgresql.org/9.1/redhat/rhel-6-x86_64/pgdg-sl91-9.1-6.noarch.rpm"
},
"5" => {
"i386" => "http://yum.postgresql.org/9.1/redhat/rhel-5-i386/pgdg-sl91-9.1-6.noarch.rpm",
"x86_64" => "http://yum.postgresql.org/9.1/redhat/rhel-5-x86_64/pgdg-sl91-9.1-6.noarch.rpm"
}
},
"fedora" => {
"16" => {
"i386" => "http://yum.postgresql.org/9.1/fedora/fedora-16-i386/pgdg-fedora91-9.1-4.noarch.rpm",
"x86_64" => "http://yum.postgresql.org/9.1/fedora/fedora-16-x86_64/pgdg-fedora91-9.1-4.noarch.rpm"
},
"15" => {
"i386" => "http://yum.postgresql.org/9.1/fedora/fedora-15-i386/pgdg-fedora91-9.1-4.noarch.rpm",
"x86_64" => "http://yum.postgresql.org/9.1/fedora/fedora-15-x86_64/pgdg-fedora91-9.1-4.noarch.rpm"
},
"14" => {
"i386" => "http://yum.postgresql.org/9.1/fedora/fedora-14-i386/pgdg-fedora91-9.1-4.noarch.rpm",
"x86_64" => "http://yum.postgresql.org/9.1/fedora/fedora-14-x86_64/pgdg-fedora-9.1-2.noarch.rpm"
}
}
},
"9.0" => {
"centos" => {
"6" => {
"i386" => "http://yum.postgresql.org/9.0/redhat/rhel-6-i386/pgdg-centos90-9.0-5.noarch.rpm",
"x86_64" => "http://yum.postgresql.org/9.0/redhat/rhel-6-x86_64/pgdg-centos90-9.0-5.noarch.rpm"
},
"5" => {
"i386" => "http://yum.postgresql.org/9.0/redhat/rhel-5-i386/pgdg-centos90-9.0-5.noarch.rpm",
"x86_64" => "http://yum.postgresql.org/9.0/redhat/rhel-5-x86_64/pgdg-centos90-9.0-5.noarch.rpm"
},
"4" => {
"i386" => "http://yum.postgresql.org/9.0/redhat/rhel-4-i386/pgdg-centos90-9.0-5.noarch.rpm",
"x86_64" => "http://yum.postgresql.org/9.0/redhat/rhel-4-x86_64/pgdg-centos90-9.0-5.noarch.rpm"
}
},
"redhat" => {
"6" => {
"i386" => "http://yum.postgresql.org/9.0/redhat/rhel-6-i386/pgdg-redhat90-9.0-5.noarch.rpm",
"x86_64" => "http://yum.postgresql.org/9.0/redhat/rhel-6-x86_64/pgdg-redhat90-9.0-5.noarch.rpm"
},
"5" => {
"i386" => "http://yum.postgresql.org/9.0/redhat/rhel-5-i386/pgdg-redhat90-9.0-5.noarch.rpm",
"x86_64" => "http://yum.postgresql.org/9.0/redhat/rhel-5-x86_64/pgdg-redhat90-9.0-5.noarch.rpm"
},
"4" => {
"i386" => "http://yum.postgresql.org/9.0/redhat/rhel-4-i386/pgdg-redhat90-9.0-5.noarch.rpm",
"x86_64" => "http://yum.postgresql.org/9.0/redhat/rhel-4-x86_64/pgdg-redhat90-9.0-5.noarch.rpm"
}
},
"scientific" => {
"6" => {
"i386" => "http://yum.postgresql.org/9.0/redhat/rhel-6-i386/pgdg-sl90-9.0-6.noarch.rpm",
"x86_64" => "http://yum.postgresql.org/9.0/redhat/rhel-6-x86_64/pgdg-sl90-9.0-6.noarch.rpm"
},
"5" => {
"i386" => "http://yum.postgresql.org/9.0/redhat/rhel-5-i386/pgdg-sl90-9.0-6.noarch.rpm",
"x86_64" => "http://yum.postgresql.org/9.0/redhat/rhel-5-x86_64/pgdg-sl90-9.0-6.noarch.rpm"
}
},
"fedora" => {
"15" => {
"i386" => "http://yum.postgresql.org/9.0/fedora/fedora-15-i386/pgdg-fedora90-9.0-5.noarch.rpm",
"x86_64" => "http://yum.postgresql.org/9.0/fedora/fedora-15-x86_64/pgdg-fedora90-9.0-5.noarch.rpm"
},
"14" => {
"i386" => "http://yum.postgresql.org/9.0/fedora/fedora-14-i386/pgdg-fedora90-9.0-5.noarch.rpm",
"x86_64" => "http://yum.postgresql.org/9.0/fedora/fedora-14-x86_64/pgdg-fedora90-9.0-5.noarch.rpm"
}
}
},
"8.4" => {
"centos" => {
"6" => {
"i386" => "http://yum.postgresql.org/8.4/redhat/rhel-6-i386/pgdg-centos-8.4-3.noarch.rpm",
"x86_64" => "http://yum.postgresql.org/8.4/redhat/rhel-6-x86_64/pgdg-centos-8.4-3.noarch.rpm"
},
"5" => {
"i386" => "http://yum.postgresql.org/8.4/redhat/rhel-5-i386/pgdg-centos-8.4-3.noarch.rpm",
"x86_64" => "http://yum.postgresql.org/8.4/redhat/rhel-5-x86_64/pgdg-centos-8.4-3.noarch.rpm"
},
"4" => {
"i386" => "http://yum.postgresql.org/8.4/redhat/rhel-4-i386/pgdg-centos-8.4-3.noarch.rpm",
"x86_64" => "http://yum.postgresql.org/8.4/redhat/rhel-4-x86_64/pgdg-centos-8.4-3.noarch.rpm"
}
},
"redhat" => {
"6" => {
"i386" => "http://yum.postgresql.org/8.4/redhat/rhel-6-i386/pgdg-redhat-8.4-3.noarch.rpm",
"x86_64" => "http://yum.postgresql.org/8.4/redhat/rhel-6-x86_64/pgdg-redhat-8.4-3.noarch.rpm"
},
"5" => {
"i386" => "http://yum.postgresql.org/8.4/redhat/rhel-5-i386/pgdg-redhat-8.4-3.noarch.rpm",
"x86_64" => "http://yum.postgresql.org/8.4/redhat/rhel-5-x86_64/pgdg-redhat-8.4-3.noarch.rpm"
},
"4" => {
"i386" => "http://yum.postgresql.org/8.4/redhat/rhel-4-i386/pgdg-redhat-8.4-3.noarch.rpm",
"x86_64" => "http://yum.postgresql.org/8.4/redhat/rhel-4-x86_64/pgdg-redhat-8.4-3.noarch.rpm"
}
},
"scientific" => {
"6" => {
"i386" => "http://yum.postgresql.org/8.4/redhat/rhel-6-i386/pgdg-sl84-8.4-4.noarch.rpm",
"x86_64" => "http://yum.postgresql.org/8.4/redhat/rhel-6-x86_64/pgdg-sl84-8.4-4.noarch.rpm"
},
"5" => {
"i386" => "http://yum.postgresql.org/8.4/redhat/rhel-5-i386/pgdg-sl-8.4-4.noarch.rpm",
"x86_64" => "http://yum.postgresql.org/8.4/redhat/rhel-5-x86_64/pgdg-sl-8.4-4.noarch.rpm"
}
},
"fedora" => {
"14" => {
"i386" => "http://yum.postgresql.org/8.4/fedora/fedora-14-i386/",
"x86_64" => "http://yum.postgresql.org/8.4/fedora/fedora-14-x86_64/"
},
"13" => {
"i386" => "http://yum.postgresql.org/8.4/fedora/fedora-13-i386/",
"x86_64" => "http://yum.postgresql.org/8.4/fedora/fedora-13-x86_64/"
},
"12" => {
"i386" => "http://yum.postgresql.org/8.4/fedora/fedora-12-i386/",
"x86_64" => "http://yum.postgresql.org/8.4/fedora/fedora-12-x86_64/"
},
"8" => {
"i386" => "http://yum.postgresql.org/8.4/fedora/fedora-8-i386/",
"x86_64" => "http://yum.postgresql.org/8.4/fedora/fedora-8-x86_64/"
},
"7" => {
"i386" => "http://yum.postgresql.org/8.4/fedora/fedora-7-i386/",
"x86_64" => "http://yum.postgresql.org/8.4/fedora/fedora-7-x86_64/"
}
}
},
};

4 changes: 4 additions & 0 deletions recipes/client.rb
Expand Up @@ -23,6 +23,10 @@
include_recipe 'postgresql::ppa_pitti_postgresql'
end

if(node['postgresql']['enable_pgdg_yum'])
include_recipe 'postgresql::yum_pgdg_postgresql'
end

node['postgresql']['client']['packages'].each do |pg_pack|

package pg_pack
Expand Down
60 changes: 60 additions & 0 deletions recipes/yum_pgdg_postgresql.rb
@@ -0,0 +1,60 @@
#
# Cookbook Name:: postgresql
# Recipe::yum_pgdg_postgresql
#
# Copyright 2013, DonorsChoose.org
#
# 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.
#

######################################
# The PostgreSQL RPM Building Project built repository RPMs for easy
# access to the PGDG yum repositories. Links to RPMs for installation
# are in an attribute so that new versions/platforms can be more
# easily added. (See attributes/default.rb)

repo_rpm_url = node['postgresql']['pgdg']['repo_rpm_url'].
fetch(node['postgresql']['version']). # e.g., fetch for "9.1"
fetch(node['platform']). # e.g., fetch for "centos"
fetch(node['platform_version'].to_f.to_i.to_s). # e.g., fetch for "5" (truncated "5.7")
fetch(node['kernel']['machine']) # e.g., fetch for "i386" or "x86_64"

# Extract the filename portion from the URL for the PGDG repository RPM.
# E.g., repo_rpm_filename = "pgdg-centos92-9.2-6.noarch.rpm"
repo_rpm_filename = File.basename(repo_rpm_url)

# Extract the package name from the URL for the PGDG repository RPM.
# E.g., repo_rpm_package = "pgdg-centos92"
repo_rpm_package = repo_rpm_filename.split(/-/,3)[0..1].join('-')

######################################
# Install the "PostgreSQL RPM Building Project - Yum Repository" through
# the repo_rpm_url determined above. The /etc/yum.repos.d/pgdg-*.repo
# will provide postgresql9X packages, but you may need to exclude
# postgresql packages from the repository of the distro in order to use
# PGDG repository properly. Conflicts will arise if postgresql9X does
# appear in your distro's repo and you want a more recent patch level.

# Download the PGDG repository RPM as a local file
remote_file "#{Chef::Config[:file_cache_path]}/#{repo_rpm_filename}" do
source "#{repo_rpm_url}"
mode "0644"
end

# Install the PGDG repository RPM from the local file
# E.g., /etc/yum.repos.d/pgdg-91-centos.repo
package "#{repo_rpm_package}" do
provider Chef::Provider::Package::Rpm
source "#{Chef::Config[:file_cache_path]}/#{repo_rpm_filename}"
action :install
end

0 comments on commit 1968bc7

Please sign in to comment.