Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contrib extensions #44

Merged
merged 9 commits into from Mar 13, 2013
33 changes: 28 additions & 5 deletions README.md
Expand Up @@ -294,11 +294,34 @@ contrib
-------

Installs the packages defined in the
`node['postgresql']['contrib']['packages']` attribute.
This is the contrib directory of the PostgreSQL distribution, which
includes porting tools, analysis utilities, and plug-in features that
database engineers often require. Some (like pgbench) are executable.
Others (like pg_buffercache) should be installed into the database.
`node['postgresql']['contrib']['packages']` attribute. The contrib
directory of the PostgreSQL distribution includes porting tools,
analysis utilities, and plug-in features that database engineers often
require. Some (like `pgbench`) are executable. Others (like
`pg_buffercache`) would need to be installed into the database.

Also installs any contrib module extensions defined in the
`node['postgresql']['contrib']['extensions']` attribute. These will be
available in any subsequently created databases in the cluster, because
they will be installed into the `template1` database using the
`CREATE EXTENSION` command. For example, it is often necessary/helpful
for problem troubleshooting and maintenance planning to install the
views and functions in these [standard instrumentation extensions]
(http://www.postgresql.org/message-id/flat/4DC32600.6080900@pgexperts.com#4DD3D6C6.5060006@2ndquadrant.com):

node['postgresql']['contrib']['extensions'] = [
"pageinspect",
"pg_buffercache",
"pg_freespacemap",
"pgrowlocks",
"pg_stat_statements",
"pgstattuple"
]

Note that the `pg_stat_statements` view only works if `postgresql.conf`
loads its shared library, which can be done with this node attribute:

node['postgresql']['config']['shared_preload_libraries'] = 'pg_stat_statements'

ppa\_pitti\_postgresql
----------------------
Expand Down
16 changes: 16 additions & 0 deletions recipes/contrib.rb
Expand Up @@ -17,8 +17,24 @@

include_recipe "postgresql::server"

# Install the PostgreSQL contrib package(s) from the distribution,
# as specified by the node attributes.
node['postgresql']['contrib']['packages'].each do |pg_pack|

package pg_pack

end

# Install PostgreSQL contrib extentions into the template1 database,
# as specified by the node attributes.
if (node['postgresql']['contrib'].attribute?('extensions'))
node['postgresql']['contrib']['extensions'].each do |pg_ext|
bash "install-#{pg_ext}-extension" do
user 'postgres'
code <<-EOH
echo "CREATE EXTENSION IF NOT EXISTS #{pg_ext};" | psql -d template1
EOH
action :run
end
end
end