Mark Bergsma has submitted this change and it was merged.

Change subject: Create simple PyBal module
......................................................................


Create simple PyBal module

Change-Id: I80968f26b48883f8e3dd5b83cdf4d6ac359c8ce8
---
A modules/pybal/manifests/configuration.pp
A modules/pybal/manifests/init.pp
A modules/pybal/templates/pybal.conf.erb
3 files changed, 63 insertions(+), 0 deletions(-)

Approvals:
  Mark Bergsma: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/modules/pybal/manifests/configuration.pp 
b/modules/pybal/manifests/configuration.pp
new file mode 100644
index 0000000..b3b9cb3
--- /dev/null
+++ b/modules/pybal/manifests/configuration.pp
@@ -0,0 +1,12 @@
+class pybal::configuration(
+    $global_options={},
+    $lvs_services,
+    $lvs_class_hosts,
+    $site) {
+
+    # Generate PyBal config file
+    file { '/etc/pybal/pybal.conf':
+        require => Package['pybal'],
+        content => template("${module_name}/pybal.conf.erb");
+    }
+}
diff --git a/modules/pybal/manifests/init.pp b/modules/pybal/manifests/init.pp
new file mode 100644
index 0000000..bc0581a
--- /dev/null
+++ b/modules/pybal/manifests/init.pp
@@ -0,0 +1,5 @@
+class pybal {
+    package { [ 'ipvsadm', 'pybal' ]:
+        ensure => installed;
+    }
+}
diff --git a/modules/pybal/templates/pybal.conf.erb 
b/modules/pybal/templates/pybal.conf.erb
new file mode 100644
index 0000000..69ef43c
--- /dev/null
+++ b/modules/pybal/templates/pybal.conf.erb
@@ -0,0 +1,46 @@
+# PyBal configuration file
+# This file is managed by Puppet!
+
+[global]
+bgp = <%= global_options.fetch('bgp', "no") %>
+bgp-local-asn = 64600
+bgp-peer-address = <%= global_options['bgp-peer-address'] %>
+#bgp-as-path = 64600 64601
+bgp-nexthop-ipv4 = <%= global_options['bgp-nexthop-ipv4'] %>
+bgp-nexthop-ipv6 = <%= global_options['bgp-nexthop-ipv6'] %>
+
+#
+# LVS service definitions
+#
+
+<% lvs_services.sort.each do |servicename, service| -%>
+<% if 
lvs_class_hosts[service['class']].include?(scope.lookupvar("::hostname")) and 
service['sites'].include?(site) then -%>
+<% if service['ip'].class.eql?(String) then
+service['ip'] = { servicename => service['ip'] }
+end -%>
+<% service['ip'].sort.each do |subservicename, subserviceip| -%>
+# SERVICE <%= subservicename %>
+# Class: <%= service['class'] %>
+# Description: <%= service['description'] %>
+# LVS balancers: <%= lvs_class_hosts[service['class']].join(" ") %>
+[<%= subservicename %>]
+protocol = <%= service.fetch('protocol', "tcp") %>
+ip = <%= subserviceip %>
+port = <%= service.fetch('port', 80) %>
+scheduler = <%= service.fetch('scheduler', "wrr") %>
+config = http://noc.wikimedia.org/pybal/<%= site %>/<%= servicename %>
+bgp = <%= service.fetch('bgp', "no") %>
+depool-threshold = <%= service.fetch('depool-threshold', ".5") %>
+monitors = <%= service['monitors'].keys.sort.inspect %>
+
+<% service['monitors'].sort.each do |monitorname, monitor| -%>
+# <%= monitorname %> monitor configuration
+<% monitor.each_pair do |param, value| -%>
+<%= monitorname.downcase %>.<%= param %> = <%= value.class == Array ? 
value.inspect : value %>
+<% end -%>
+<% end -%>
+
+<% end -%>
+
+<% end -%>
+<% end -%>

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I80968f26b48883f8e3dd5b83cdf4d6ac359c8ce8
Gerrit-PatchSet: 3
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Mark Bergsma <m...@wikimedia.org>
Gerrit-Reviewer: Mark Bergsma <m...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot

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

Reply via email to