Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Contrib extensions #44

Merged
merged 9 commits into from
This page is out of date. Refresh to see the latest.
Showing with 44 additions and 5 deletions.
  1. +28 −5 README.md
  2. +16 −0 recipes/contrib.rb
View
33 README.md
@@ -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
----------------------
View
16 recipes/contrib.rb
@@ -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
Something went wrong with that request. Please try again.