Rush has uploaded a new change for review.

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

Change subject: labstore: drbd resource setup sanity
......................................................................

labstore: drbd resource setup sanity

* only use an fqdn for ipresolve() things
* consolidate cluster info into one data structure
* remove /etc/hosts entries for `hostname`

Change-Id: Idb58e2d65df91834448c9c53e787094e1f0d0c43
---
M modules/labstore/manifests/drbd/resource.pp
M modules/labstore/templates/drbd/drbd_resource.res.erb
M modules/role/manifests/labs/nfs/secondary.pp
3 files changed, 41 insertions(+), 54 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/23/312023/1

diff --git a/modules/labstore/manifests/drbd/resource.pp 
b/modules/labstore/manifests/drbd/resource.pp
index e1d41e9..e080d93 100644
--- a/modules/labstore/manifests/drbd/resource.pp
+++ b/modules/labstore/manifests/drbd/resource.pp
@@ -18,15 +18,15 @@
 # 6a. drbdadm primary --force $resource
 # 7. Format /dev/drbdx
 #
-# [*nodes]
-#  Array with 2 values containing the node names where the resources are
-#  meant to be available. Typically one of these nodes will be designated
-#  primary, and the other secondary.
-#  ** must match $::hostname
+# [*drbd_cluster]
+#  Hash that has the `hostname` of each node with the associated
+#  FQDN to use for replication (this is most likely a secondary interface).
+#  {'nfs1' => 'eth1.nfs1.domain', 'nfs2' => eth1.nfs2.domain'}
 #
-# [*addresses]
-#  Array of resolvable fqdn to peer with for DRBD (is translated to IP), can 
be the same
-#  as nodes definitons or distinct.
+#  ** the 'hostname' here should match literal `hostname` for the relevant node
+#     in the cluster for DRBD to function correctly.  This is not used
+#     for resolution.  Using the FQDN or another representation causes
+#     DRBD to ignore the resource.
 #
 # [*port]
 #  Integer port number for DRBD TCP connections. Needs to be unique for
@@ -40,17 +40,15 @@
 #
 # Example:
 # labstore::drbd_resource {'myresource':
-#     nodes   => ['host1', 'host2'],
-#     addresses => ['eth1.host1', 'eth1.host2'],
-#     port    => 7788,
-#     device  => '/dev/drbd1',
-#     disk    => '/dev/misc/blockdevice',
+#     drbd_cluster => {'nfs1' => 'eth1.nfs1.domain', 'nfs2' => 
eth1.nfs2.domain'},
+#     port         => 7788,
+#     device       => '/dev/drbd1',
+#     disk         => '/dev/misc/blockdevice',
 # }
 #
 
 define labstore::drbd::resource (
-    $nodes,
-    $addresses,
+    $drbd_cluster,
     $port,
     $device,
     $disk,
@@ -58,8 +56,10 @@
 
     require labstore::drbd::node
 
-    if size(unique($nodes)) != 2 {
-        fail('specify two nodes by hostname')
+    $drbd_hosts = keys($drbd_cluster)
+
+    if size(unique($drbd_hosts)) != 2 {
+        fail('specify two nodes by hostname as keys')
     }
 
     # cheap way to ensure uniqueness across resources
@@ -81,18 +81,6 @@
         onlyif      => "/sbin/drbdadm role ${name} | grep -i -e ^primary -e 
^secondary",
         logoutput   => true,
         refreshonly => true,
-    }
-
-    if !defined(Host[$nodes[0]]) {
-        host { $nodes[0]:
-            ip => ipresolve($nodes[0]),
-        }
-    }
-
-    if !defined(Host[$nodes[1]]) {
-        host { $nodes[1]:
-            ip => ipresolve($nodes[1]),
-        }
     }
 }
 
diff --git a/modules/labstore/templates/drbd/drbd_resource.res.erb 
b/modules/labstore/templates/drbd/drbd_resource.res.erb
index 6bb4027..8d25202 100644
--- a/modules/labstore/templates/drbd/drbd_resource.res.erb
+++ b/modules/labstore/templates/drbd/drbd_resource.res.erb
@@ -1,15 +1,15 @@
 resource <%= @name %> {
 
-  on <%= @nodes.first %> {
+  on <%= @drbd_hosts.first %> {
     device    <%= @device %>;
-    address   <%= scope.function_ipresolve([@addresses.first, 4]) %>:<%= @port 
%>;
+    address   <%= scope.function_ipresolve([@drbd_cluster[@drbd_hosts.first], 
4]) %>:<%= @port %>;
     disk      <%= @disk %>;
     meta-disk internal;
   }
 
-  on <%= @nodes.last %> {
+  on <%= @drbd_hosts.last %> {
     device    <%= @device %>;
-    address   <%= scope.function_ipresolve([@addresses.last, 4]) %>:<%= @port 
%>;
+    address   <%= scope.function_ipresolve([@drbd_cluster[@drbd_hosts.last], 
4]) %>:<%= @port %>;
     disk      <%= @disk %>;
     meta-disk internal;
   }
diff --git a/modules/role/manifests/labs/nfs/secondary.pp 
b/modules/role/manifests/labs/nfs/secondary.pp
index 104120f..0281cd2 100644
--- a/modules/role/manifests/labs/nfs/secondary.pp
+++ b/modules/role/manifests/labs/nfs/secondary.pp
@@ -27,34 +27,33 @@
         }
     }
 
-    $nodes = ['labstore1004', 'labstore1005']
-    $addresses = ['eth1.labstore1004.eqiad.wmnet',
-                  'eth1.labstore1005.eqiad.wmnet']
+    # TODO: hiera this
+    $drbd_cluster = {
+        'labstore1004' => 'eth1.labstore1004.eqiad.wmnet',
+        'labstore1005' => 'eth1.labstore1005.eqiad.wmnet',
+    }
 
     labstore::drbd::resource {'test':
-        nodes     => $nodes,
-        addresses => $addresses,
-        port      => '7790',
-        device    => '/dev/drbd1',
-        disk      => '/dev/misc/test',
-        require   => Interface::Ip['drbd-replication'],
+        drbd_cluster => $drbd_cluster
+        port         => '7790',
+        device       => '/dev/drbd1',
+        disk         => '/dev/misc/test',
+        require      => Interface::Ip['drbd-replication'],
     }
 
     labstore::drbd::resource {'tools':
-        nodes     => $nodes,
-        addresses => $addresses,
-        port      => '7791',
-        device    => '/dev/drbd2',
-        disk      => '/dev/tools-project/tools-project',
-        require   => Interface::Ip['drbd-replication'],
+        drbd_cluster => $drbd_cluster
+        port         => '7791',
+        device       => '/dev/drbd2',
+        disk         => '/dev/tools-project/tools-project',
+        require      => Interface::Ip['drbd-replication'],
     }
 
     labstore::drbd::resource {'others':
-        nodes     => $nodes,
-        addresses => $addresses,
-        port      => '7792',
-        device    => '/dev/drbd3',
-        disk      => '/dev/misc/others',
-        require   => Interface::Ip['drbd-replication'],
+        drbd_cluster => $drbd_cluster
+        port         => '7792',
+        device       => '/dev/drbd3',
+        disk         => '/dev/misc/others',
+        require      => Interface::Ip['drbd-replication'],
     }
 }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Idb58e2d65df91834448c9c53e787094e1f0d0c43
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Rush <r...@wikimedia.org>

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

Reply via email to