Rush has uploaded a new change for review.
https://gerrit.wikimedia.org/r/217973
Change subject: confd additions for pybal
......................................................................
confd additions for pybal
* A golang template for generating external
node pool definition files that are already
accepted by pybal
* A brief script to validate the definition file
Change-Id: I634bbf70bea2865bdf3e012c5f7c8b4a75450a46
---
A modules/pybal/files/pybal-eval-check.py
M modules/pybal/manifests/init.pp
A modules/pybal/templates/host-pool.tmpl.erb
3 files changed, 38 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/operations/puppet
refs/changes/73/217973/1
diff --git a/modules/pybal/files/pybal-eval-check.py
b/modules/pybal/files/pybal-eval-check.py
new file mode 100644
index 0000000..02f7cd6
--- /dev/null
+++ b/modules/pybal/files/pybal-eval-check.py
@@ -0,0 +1,20 @@
+#!/usr/bin/env python
+# This is a simple validator for external pybal node
+# definition files. These are loaded and eval'd
+# line by line. A faulty eval will cause issues.
+
+import sys
+file = open(sys.argv[1], 'r').read()
+for l in file.splitlines():
+ #this mimics internal pybal behavior
+ l = l.rstrip('\n').strip()
+ if l.startswith('#') or not l:
+ continue
+
+ try:
+ server = eval(l)
+ assert type(server) == dict
+ assert all(map(lambda k: k in server, ['host', 'enabled', 'weight']))
+ except Exception as e:
+ print l, e
+ sys.exit(1)
diff --git a/modules/pybal/manifests/init.pp b/modules/pybal/manifests/init.pp
index bc0581a..820045f 100644
--- a/modules/pybal/manifests/init.pp
+++ b/modules/pybal/manifests/init.pp
@@ -1,5 +1,12 @@
class pybal {
+
package { [ 'ipvsadm', 'pybal' ]:
ensure => installed;
}
+
+ file { '/usr/local/bin/pybal-eval-check':
+ ensure => file,
+ mode => '0555',
+ source => 'puppet:///modules/pybal/pybal-eval-check.py',
+ }
}
diff --git a/modules/pybal/templates/host-pool.tmpl.erb
b/modules/pybal/templates/host-pool.tmpl.erb
new file mode 100644
index 0000000..7e58fc9
--- /dev/null
+++ b/modules/pybal/templates/host-pool.tmpl.erb
@@ -0,0 +1,11 @@
+# This file is managed by puppet.
+# This is a golang template (http://golang.org/pkg/text/template/)
+# for creating an external node pool reference file
+
+<% @watch_keys.each do |key| -%>
+{{range $node := ls "<%= key %>"}}
+{{ $key := printf "<%= key %>%s" $node }}
+{{ $data := json (getv $key) }}
+{{ if ne $data.pooled "inactive" }}
+{'host':'{{ $node }}.eqiad.wmnet', 'enabled':{{if eq $data.pooled
"yes"}}True{{else}}False{{end}}, 'weight':{{ $data.weight}} }{{end}}{{end}}
+<% end -%>
--
To view, visit https://gerrit.wikimedia.org/r/217973
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I634bbf70bea2865bdf3e012c5f7c8b4a75450a46
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Rush <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits