Alexandros Kosiaris has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/224864

Change subject: Allow speficying postgis version in postgresql::spatialdb
......................................................................

Allow speficying postgis version in postgresql::spatialdb

Using postgis 2.1 uses a different approach when being installed than
1.5. Amend postgresql::spatialdb to account for this.

Change-Id: Id51198c9e4140753d6edca8ade5eae78a4ccbad9
---
M modules/postgresql/manifests/spatialdb.pp
1 file changed, 46 insertions(+), 38 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/64/224864/1

diff --git a/modules/postgresql/manifests/spatialdb.pp 
b/modules/postgresql/manifests/spatialdb.pp
index a06ae15..239d2e0 100644
--- a/modules/postgresql/manifests/spatialdb.pp
+++ b/modules/postgresql/manifests/spatialdb.pp
@@ -17,6 +17,7 @@
 define postgresql::spatialdb(
     $ensure = 'present',
     $pg_version = '9.1',
+    $postgis_version = '1.5',
     ) {
 
     # Check if our db exists and store it
@@ -32,50 +33,57 @@
             user    => 'postgres',
             unless  => $db_exists,
         }
-        exec { "create_plpgsql_lang-${name}":
-            command => "/usr/bin/createlang plpgsql ${name}",
-            user    => 'postgres',
-            unless  => $plpgsql_exists,
-        }
-        exec { "create_postgis-${name}":
-            command => "/usr/bin/psql -d ${name} -f 
/usr/share/postgresql/${pg_version}/contrib/postgis-1.5/postgis.sql",
-            user    => 'postgres',
-            unless  => $postgis_exists,
-        }
-        # Create spatial_ref_sys
-        exec { "create_spatial_ref_sys-${name}":
-            command     => "/usr/bin/psql -d ${name} -f 
/usr/share/postgresql/${pg_version}/contrib/postgis-1.5/spatial_ref_sys.sql",
-            user        => 'postgres',
-            refreshonly => true,
-            subscribe   => Exec["create_postgis-${name}"],
-        }
-        exec { "grant_ref_sys_cmd-${name}":
-            command     => "/usr/bin/psql -d ${name} -c \"GRANT SELECT ON 
spatial_ref_sys TO PUBLIC;\"",
-            user        => 'postgres',
-            refreshonly => true,
-            subscribe   => Exec["create_spatial_ref_sys-${name}"],
-        }
-        # Create comments
-        exec { "create_comments-${name}":
-            command     => "/usr/bin/psql -d ${name} -f 
/usr/share/postgresql/${pg_version}/contrib/postgis_comments.sql",
-            user        => 'postgres',
-            refreshonly => true,
-            subscribe   => Exec["create_spatial_ref_sys-${name}"],
-        }
-        exec { "grant_comments_cmd-${name}":
-            command     => "/usr/bin/psql -d ${name} -c \"GRANT ALL ON 
geometry_columns TO PUBLIC;\"",
-            user        => 'postgres',
-            refreshonly => true,
-            subscribe   => Exec["create_comments-${name}"],
+        if $postgis_version == '1.5' {
+            exec { "create_plpgsql_lang-${name}":
+                command => "/usr/bin/createlang plpgsql ${name}",
+                user    => 'postgres',
+                unless  => $plpgsql_exists,
+            }
+            exec { "create_postgis-${name}":
+                command => "/usr/bin/psql -d ${name} -f 
/usr/share/postgresql/${pg_version}/contrib/postgis-${postgis_version}/postgis.sql",
+                user    => 'postgres',
+                unless  => $postgis_exists,
+            }
+            # Create spatial_ref_sys
+            exec { "create_spatial_ref_sys-${name}":
+                command     => "/usr/bin/psql -d ${name} -f 
/usr/share/postgresql/${pg_version}/contrib/postgis-1.5/spatial_ref_sys.sql",
+                user        => 'postgres',
+                refreshonly => true,
+                subscribe   => Exec["create_postgis-${name}"],
+            }
+            exec { "grant_ref_sys_cmd-${name}":
+                command     => "/usr/bin/psql -d ${name} -c \"GRANT SELECT ON 
spatial_ref_sys TO PUBLIC;\"",
+                user        => 'postgres',
+                refreshonly => true,
+                subscribe   => Exec["create_spatial_ref_sys-${name}"],
+            }
+            exec { "create_comments-${name}":
+                command     => "/usr/bin/psql -d ${name} -f 
/usr/share/postgresql/${pg_version}/contrib/postgis_comments.sql",
+                user        => 'postgres',
+                refreshonly => true,
+                subscribe   => Exec["create_spatial_ref_sys-${name}"],
+            }
+            # Create comments
+            exec { "grant_comments_cmd-${name}":
+                command     => "/usr/bin/psql -d ${name} -c \"GRANT ALL ON 
geometry_columns TO PUBLIC;\"",
+                user        => 'postgres',
+                refreshonly => true,
+                subscribe   => Exec["create_comments-${name}"],
+            }
+        } else {
+            exec { "create_postgis-${name}":
+                command     => "/usr/bin/psql -d ${name} -c \"CREATE EXTENSION 
postgis;\"",
+                user        => 'postgres',
+                refreshonly => true,
+                subscribe   => Exec["create_db-${name}"],
+            }
         }
         exec { "create_extension_hstore-${name}":
             command     => "/usr/bin/psql -d ${name} -c \"CREATE EXTENSION 
hstore;\"",
             user        => 'postgres',
             refreshonly => true,
-            subscribe   => Exec["create_comments-${name}"],
+            subscribe   => Exec["create_db-${name}"],
         }
-        Exec["create_db-${name}"] -> Exec["create_plpgsql_lang-${name}"]
-        Exec["create_plpgsql_lang-${name}"] -> Exec["create_postgis-${name}"]
     } elsif $ensure == 'absent' {
         exec { "drop_db-${name}":
             command => "/usr/bin/dropdb ${name}",

-- 
To view, visit https://gerrit.wikimedia.org/r/224864
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id51198c9e4140753d6edca8ade5eae78a4ccbad9
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Alexandros Kosiaris <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to