Alexandros Kosiaris has uploaded a new change for review.

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

Change subject: postgres: Provide new packages class for others to rely on
......................................................................

postgres: Provide new packages class for others to rely on

We want to have some things run after the packages are installed  but
not after the service has been started. To achieve this, split off the
postgresql packages to it's own class and require that as needed

Change-Id: Iaf9b4f1a015849f7c3a4eaa466caebcd412b7734
---
A modules/postgresql/manifests/packages.pp
M modules/postgresql/manifests/server.pp
M modules/postgresql/manifests/slave.pp
3 files changed, 45 insertions(+), 14 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/95/310795/1

diff --git a/modules/postgresql/manifests/packages.pp 
b/modules/postgresql/manifests/packages.pp
new file mode 100644
index 0000000..cefed50
--- /dev/null
+++ b/modules/postgresql/manifests/packages.pp
@@ -0,0 +1,42 @@
+# Class: postgresql::packages
+#
+# This class installs postgresql packages. It is split off from the rest of the
+# classes in order to allow them to require it with no side-effects
+#
+# Parameters:
+#   pgversion
+#       Defaults to 9.1 in Ubuntu Precise, 9.3 in Ubuntu Trusty,
+#       and 9.4 in Debian Jessie. Ubuntu Precise may choose 8.4.
+#       FIXME: Just use the unversioned package name and let apt
+#       do the right thing.
+#   ensure
+#       Defaults to present
+#
+# Actions:
+#  Install postgresql
+#
+# Requires:
+#
+# Sample Usage:
+#  include postgresql::packages
+#
+class postgresql::packages(
+    $pgversion        = $::lsbdistcodename ? {
+        jessie  => '9.4',
+        precise => '9.1',
+        trusty  => '9.3',
+    },
+    $ensure           = 'present',
+) {
+    package { [
+        "postgresql-${pgversion}",
+        "postgresql-${pgversion}-debversion",
+        "postgresql-client-${pgversion}",
+        "postgresql-contrib-${pgversion}",
+        'libdbi-perl',
+        'libdbd-pg-perl',
+        'ptop',
+    ]:
+        ensure => $ensure,
+    }
+}
diff --git a/modules/postgresql/manifests/server.pp 
b/modules/postgresql/manifests/server.pp
index eb68f5c..0ab56e8 100644
--- a/modules/postgresql/manifests/server.pp
+++ b/modules/postgresql/manifests/server.pp
@@ -40,17 +40,7 @@
     $root_dir         = '/var/lib/postgresql',
     $use_ssl          = false,
 ) {
-    package { [
-        "postgresql-${pgversion}",
-        "postgresql-${pgversion}-debversion",
-        "postgresql-client-${pgversion}",
-        "postgresql-contrib-${pgversion}",
-        'libdbi-perl',
-        'libdbd-pg-perl',
-        'ptop',
-    ]:
-        ensure => $ensure,
-    }
+    require ::postgresql::packages
 
     $data_dir = "${root_dir}/${pgversion}/main"
 
@@ -65,7 +55,6 @@
         owner   => 'postgres',
         group   => 'postgres',
         mode    => '0755',
-        require => Package["postgresql-${pgversion}"],
     }
 
     file { $data_dir:
@@ -102,7 +91,6 @@
 
     service { $service_name:
         ensure  => ensure_service($ensure),
-        require => Package["postgresql-${pgversion}"]
     }
 
     file { "/etc/postgresql/${pgversion}/main/postgresql.conf":
diff --git a/modules/postgresql/manifests/slave.pp 
b/modules/postgresql/manifests/slave.pp
index 6f4c5bf..4b0c1be 100644
--- a/modules/postgresql/manifests/slave.pp
+++ b/modules/postgresql/manifests/slave.pp
@@ -41,6 +41,7 @@
     $root_dir='/var/lib/postgresql',
     $use_ssl=false,
 ) {
+    require ::postgresql::packages
 
     $data_dir = "${root_dir}/${pgversion}/main"
 
@@ -80,7 +81,7 @@
             command     => "/usr/bin/pg_basebackup -X stream -D ${data_dir} -h 
${master_server} -U replication -w",
             user        => 'postgres',
             unless      => "/usr/bin/test -f ${data_dir}/PG_VERSION",
-            require     => Class['postgresql::server'],
+            before      => Class['postgresql::server'],
         }
     }
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iaf9b4f1a015849f7c3a4eaa466caebcd412b7734
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Alexandros Kosiaris <akosia...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to