Rush has submitted this change and it was merged.
Change subject: Setup a node pool file from etcd for lvs cluster
......................................................................
Setup a node pool file from etcd for lvs cluster
With a conftool cluster and service definition
included in the lvs::configuration cluster hash
we setup a confd toml and template to allow
external definition of nodes in the pool. The
config line change to actually use this etcd
sourced config is commented out as this will
rollout slowly.
Example of confd files created for 'text':
/etc/confd/
├── conf.d
│ └── _etc_pybal_pools_text.toml
└── templates
└── _etc_pybal_pools_text.tmpl
Example toml file:
[template]
src = "_etc_pybal_pools_text.tmpl"
dest = "/etc/pybal/pools/text"
mode = "0444"
keys = [
"/conftool/v1/pools/eqiad/cache_text/varnish-fe/",
]
check_cmd = "/usr/local/bin/pybal-eval-check {{.src}}"
This change assumes each lvs service has a conftool service
and cluster reference.
Change-Id: I6c0179738bc3dab0170a5ccba20f53cd42a06b79
---
M modules/confd/manifests/file.pp
M modules/lvs/manifests/balancer.pp
M modules/pybal/manifests/confd.pp
M modules/pybal/manifests/configuration.pp
A modules/pybal/manifests/pool.pp
M modules/pybal/templates/pybal.conf.erb
6 files changed, 60 insertions(+), 6 deletions(-)
Approvals:
Rush: Looks good to me, approved
jenkins-bot: Verified
diff --git a/modules/confd/manifests/file.pp b/modules/confd/manifests/file.pp
index d8fe1b6..78f2590 100644
--- a/modules/confd/manifests/file.pp
+++ b/modules/confd/manifests/file.pp
@@ -17,16 +17,19 @@
include ::confd
$safe_name = regsubst($name, '/', '_', 'G')
- #TODO validate at least uid and guid
- file { "/etc/confd/conf.d/${safe_name}.toml":
- ensure => $ensure,
- content => template('confd/service_template.toml.erb'),
- }
-
file { "/etc/confd/templates/${safe_name}.tmpl":
ensure => $ensure,
mode => '0400',
content => $content,
+ require => Package['confd'],
+ before => File["/etc/confd/conf.d/${safe_name}.toml"],
+ }
+
+ #TODO validate at least uid and guid
+ file { "/etc/confd/conf.d/${safe_name}.toml":
+ ensure => $ensure,
+ content => template('confd/service_template.toml.erb'),
notify => Service['confd'],
}
+
}
diff --git a/modules/lvs/manifests/balancer.pp
b/modules/lvs/manifests/balancer.pp
index 62b39d5..f72dbf5 100644
--- a/modules/lvs/manifests/balancer.pp
+++ b/modules/lvs/manifests/balancer.pp
@@ -16,6 +16,7 @@
) {
include pybal
+ include pybal::confd
include cpufrequtils # defaults to "performance", Ubuntu default is
"ondemand"
# ethtool is also a package needed but it is included from base
diff --git a/modules/pybal/manifests/confd.pp b/modules/pybal/manifests/confd.pp
index e229eec..e39ef77 100644
--- a/modules/pybal/manifests/confd.pp
+++ b/modules/pybal/manifests/confd.pp
@@ -1,5 +1,12 @@
+# Resources required for pybal/confd interaction
+#
class pybal::confd {
+ file { '/etc/pybal/pools':
+ ensure => directory,
+ require => Package[pybal],
+ }
+
file { '/usr/local/bin/pybal-eval-check':
ensure => file,
mode => '0555',
diff --git a/modules/pybal/manifests/configuration.pp
b/modules/pybal/manifests/configuration.pp
index b3b9cb3..6c17c6d 100644
--- a/modules/pybal/manifests/configuration.pp
+++ b/modules/pybal/manifests/configuration.pp
@@ -9,4 +9,10 @@
require => Package['pybal'],
content => template("${module_name}/pybal.conf.erb");
}
+
+ $service_keys = keys($lvs_services)
+ pybal::pool {$service_keys:
+ lvs_services => $lvs_services,
+ lvs_class_hosts => $lvs_class_hosts
+ }
}
diff --git a/modules/pybal/manifests/pool.pp b/modules/pybal/manifests/pool.pp
new file mode 100644
index 0000000..62f46ad
--- /dev/null
+++ b/modules/pybal/manifests/pool.pp
@@ -0,0 +1,36 @@
+# Establishes the Confd setup for relevant lvs services
+#
+# === Parameters
+#
+# [*lvs_services*]
+# lvs_services hash from lvs/configuration.pp
+#
+# [*lvs_class_hosts*]
+# lvs_class_hosts hash from lvs/configuration.pp
+#
+define pybal::pool(
+ $lvs_services={},
+ $lvs_class_hosts={},
+) {
+
+ $service_config = $lvs_services[$name]
+
+ # This shadows pybal template for selection
+ if member($service_config['sites'], $::site) {
+ if member($lvs_class_hosts[$service_config['class']], $::hostname) {
+
+ $cluster = $service_config['conftool']['cluster']
+ $service = $service_config['conftool']['service']
+
+ $watch_keys = ["/conftool/v1/pools/$::site/$cluster/$service/"]
+ $tmpl = template('pybal/host-pool.tmpl.erb')
+
+ confd::file{ "/etc/pybal/pools/$name":
+ watch_keys => $watch_keys,
+ content => $tmpl,
+ check => '/usr/local/bin/pybal-eval-check',
+ require => File['/etc/pybal/pools'],
+ }
+ }
+ }
+}
diff --git a/modules/pybal/templates/pybal.conf.erb
b/modules/pybal/templates/pybal.conf.erb
index d0ee898..83cc321 100644
--- a/modules/pybal/templates/pybal.conf.erb
+++ b/modules/pybal/templates/pybal.conf.erb
@@ -29,6 +29,7 @@
port = <%= service.fetch('port', 80) %>
scheduler = <%= service.fetch('scheduler', "wrr") %>
config = http://config-master.<%= @site %>.wmnet/pybal/<%= @site %>/<%=
servicename %>
+# config = file:///etc/pybal/pools/<%= servicename %>
bgp = <%= service.fetch('bgp', "no") %>
depool-threshold = <%= service.fetch('depool-threshold', ".5") %>
monitors = <%= service['monitors'].keys.sort.inspect %>
--
To view, visit https://gerrit.wikimedia.org/r/219481
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I6c0179738bc3dab0170a5ccba20f53cd42a06b79
Gerrit-PatchSet: 9
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Rush <[email protected]>
Gerrit-Reviewer: BBlack <[email protected]>
Gerrit-Reviewer: Giuseppe Lavagetto <[email protected]>
Gerrit-Reviewer: Rush <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits