Ottomata has submitted this change and it was merged.

Change subject: Puppet configuration for new elasticsearch servers
......................................................................


Puppet configuration for new elasticsearch servers

Refactors role::elasticsearch::(labs|beta|production) into
role::elassticsearch::config and role::elasticsearch like Kafka.  This
makes sure there are parameters to the role class

Also sets up minimum_master_nodes, master_eligible, and holds_data.

Also retires testsearch100[1-3].

Change-Id: Ic30396c1f47767b05a8e0cfe51693f845e763715
---
M manifests/role/elasticsearch.pp
M manifests/site.pp
M modules/elasticsearch/manifests/init.pp
M modules/elasticsearch/templates/elasticsearch.yml.erb
4 files changed, 84 insertions(+), 61 deletions(-)

Approvals:
  Ottomata: Verified; Looks good to me, approved



diff --git a/manifests/role/elasticsearch.pp b/manifests/role/elasticsearch.pp
index 90e4de4..f4e1693 100644
--- a/manifests/role/elasticsearch.pp
+++ b/manifests/role/elasticsearch.pp
@@ -1,53 +1,66 @@
-# = Class: role::elasticsearch::production
+# = Class: role::elasticsearch::config
 #
-# This class manages an elasticsearch service in a WMF-specific way for
-# production.
+# This class sets up Elasticsearch configuration in a WMF-specific way.
 #
-class role::elasticsearch::production {
-    $multicast_group = $::site ? {
-        'eqiad' => '224.2.2.5',
-        'pmtpa' => '224.2.2.6',
+class role::elasticsearch::config {
+    # Config
+    if ($::realm == 'labs') {
+        $multicast_group = '224.2.2.4'
+        $master_eligible = true
+        if ($::hostname =~ /^deployment-/) {
+            # Beta
+            # Has four nodes all of which can be master
+            $minimum_master_nodes = 3
+            $cluster_name         = 'beta-search'
+            $heap_memory          = '4G'
+        } else {
+            # Regular labs instance
+            # We don't know how many instances will be in each labs project so
+            # we got with the lowest common denominator assuming that you can
+            # recover from a split brain on your own.  It'd be good practice
+            # in case we have one in production.
+            $minimum_master_nodes = 1
+            # This should be configured per project
+            if $::elasticsearch_cluster_name == undef {
+                $message = 'must be set to something unique to the labs 
project'
+                fail("\$::elasticsearch_cluster_name $message")
+            }
+            $cluster_name         = $::elasticsearch_cluster_name
+            $heap_memory          = '2G'
+        }
+    } else {
+        # Production
+        $multicast_group = $::site ? {
+            'eqiad' => '224.2.2.5',
+            'pmtpa' => '224.2.2.6',
+        }
+        $master_eligible = $::hostname ? {
+            /^elastic1001/        => true,  # Rack A3
+            /^elastic1007/        => true,  # Rack C5
+            # TODO Move this when we get machines on another row/rack
+            /^elastic1012/        => true,  # Rack C5
+            default               => false,
+        }
+        $minimum_master_nodes = 2
+        $cluster_name         = "production-search-${::site}"
+        $heap_memory          = '30G'
     }
-    class { '::elasticsearch':
-        cluster_name    => "production-search-${::site}",
-        heap_memory     => '7G',
-        multicast_group => $multicast_group,
-        plugins_dir     => '/srv/deployment/elasticsearch/plugins',
-    }
-    deployment::target { 'elasticsearchplugins': }
-
-    include elasticsearch::ganglia
-    include elasticsearch::nagios::check
 }
 
-# = Class: role::elasticsearch::beta
+# = Class: role::elasticsearch
 #
-# This class manages an elasticsearch service in a WMF-specific way for beta.
+# This class sets up Elasticsearch in a WMF-specific way.
 #
-class role::elasticsearch::beta {
-    class { '::elasticsearch':
-        cluster_name => 'beta-search',
-        heap_memory  => '4G',
-        plugins_dir  => '/srv/deployment/elasticsearch/plugins',
-    }
-    deployment::target { 'elasticsearchplugins': }
+class role::elasticsearch inherits role::elasticsearch::config {
 
-    include elasticsearch::ganglia
-    include elasticsearch::nagios::check
-}
-
-# = Class: role::elasticsearch::labs
-#
-# This class manages an elasticsearch service in a WMF-specific way for labs.
-# Note that this requires the elasticsearch_cluster_name global to be set.
-#
-class role::elasticsearch::labs {
-    if $::elasticsearch_cluster_name == undef {
-        fail("$::elasticsearch_cluster_name must be set to something unique 
for your cluster")
-    }
+    # Install
     class { '::elasticsearch':
-        cluster_name => $::elasticsearch_cluster_name,
-        plugins_dir  => '/srv/deployment/elasticsearch/plugins',
+        multicast_group      => $multicast_group,
+        master_eligible      => $master_eligible,
+        minimum_master_nodes => $minimum_master_nodes,
+        cluster_name         => $cluster_name,
+        heap_memory          => $heap_memory,
+        plugins_dir          => '/srv/deployment/elasticsearch/plugins',
     }
     deployment::target { 'elasticsearchplugins': }
 
diff --git a/manifests/site.pp b/manifests/site.pp
index c947c7d..d688442 100644
--- a/manifests/site.pp
+++ b/manifests/site.pp
@@ -904,18 +904,6 @@
         misc::mediawiki-irc-relay
 }
 
-node /^elastic10(0[1-9]|1[0-2])\.eqiad\.wmnet$/ {
-    include accounts::manybubbles,
-        accounts::demon,
-        groups::wikidev
-
-    sudo_user { [ "manybubbles" ]: privileges => ['ALL = NOPASSWD: ALL'] }
-    sudo_user { [ "demon" ]: privileges => ['ALL = NOPASSWD: ALL'] }
-
-    include standard
-    include role::elasticsearch::production
-}
-
 # base_analytics_logging_node is defined in role/logging.pp
 node "emery.wikimedia.org" inherits "base_analytics_logging_node" {
     include
@@ -2770,7 +2758,19 @@
     sudo_user { [ "demon" ]: privileges => ['ALL = NOPASSWD: ALL'] }
 
     include standard
-    include role::elasticsearch::production
+    include elasticsearch::decommission
+}
+
+node /^elastic10(0[1-9]|1[0-2])\.eqiad\.wmnet/ {
+    include accounts::manybubbles,
+        accounts::demon,
+        groups::wikidev
+
+    sudo_user { [ "manybubbles" ]: privileges => ['ALL = NOPASSWD: ALL'] }
+    sudo_user { [ "demon" ]: privileges => ['ALL = NOPASSWD: ALL'] }
+
+    include standard
+    include role::elasticsearch
     class { "lvs::realserver": realserver_ips => [ "10.2.2.30" ] }
 }
 
diff --git a/modules/elasticsearch/manifests/init.pp 
b/modules/elasticsearch/manifests/init.pp
index 3a13280..028108c 100644
--- a/modules/elasticsearch/manifests/init.pp
+++ b/modules/elasticsearch/manifests/init.pp
@@ -12,6 +12,13 @@
 #       smaller.
 # - $multicast_group:  multicast group to use for peer discovery.  Defaults to
 #       elasticsearch's default: '224.2.2.4'.
+# - $minimum_master_nodes:  how many master nodes must be online for this node
+#       to believe that the Elasticsearch cluster is functioning correctly.
+#       Defaults to 1.  Should be set to number of master eligible nodes in
+#       cluster / 2 + 1.
+# - $master_eligible:  is this node eligible to be a master node?  Defaults to
+#       true.
+# - $holds_data: should this node hold data?  Defaults to true.
 #
 # == Sample usage:
 #
@@ -22,7 +29,10 @@
 class elasticsearch($cluster_name,
                     $heap_memory = '2G',
                     $multicast_group = '224.2.2.4',
-                    $plugins_dir = '/usr/share/elasticsearch/plugins') {
+                    $plugins_dir = '/usr/share/elasticsearch/plugins',
+                    $minimum_master_nodes = 1,
+                    $master_eligible = true,
+                    $holds_data = true) {
     # Check arguments
     if $cluster_name == 'elasticsearch' {
         fail('$cluster_name must not be set to "elasticsearch"')
diff --git a/modules/elasticsearch/templates/elasticsearch.yml.erb 
b/modules/elasticsearch/templates/elasticsearch.yml.erb
index 5190cea..f05759f 100644
--- a/modules/elasticsearch/templates/elasticsearch.yml.erb
+++ b/modules/elasticsearch/templates/elasticsearch.yml.erb
@@ -43,12 +43,12 @@
 # and to allow or deny to store the data.
 #
 # Allow this node to be eligible as a master node (enabled by default):
-#
-# node.master: true
-#
+
+node.master: <%= @master_eligible %>
+
 # Allow this node to store data (enabled by default):
-#
-# node.data: true
+
+node.data: <%= @holds_data %>
 
 # You can exploit these settings to design advanced cluster topologies.
 #
@@ -300,7 +300,7 @@
 # operational within the cluster. Set this option to a higher value (2-4)
 # for large clusters (>3 nodes):
 #
-# discovery.zen.minimum_master_nodes: 1
+discovery.zen.minimum_master_nodes: <%= @minimum_master_nodes %>
 discovery.zen.ping.multicast.group: <%= @multicast_group %>
 
 # Set the time to wait for ping responses from other nodes when discovering.

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ic30396c1f47767b05a8e0cfe51693f845e763715
Gerrit-PatchSet: 10
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Manybubbles <[email protected]>
Gerrit-Reviewer: Andrew Bogott <[email protected]>
Gerrit-Reviewer: Chad <[email protected]>
Gerrit-Reviewer: MZMcBride <[email protected]>
Gerrit-Reviewer: Manybubbles <[email protected]>
Gerrit-Reviewer: Ottomata <[email protected]>
Gerrit-Reviewer: jenkins-bot

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

Reply via email to