Mobrovac has uploaded a new change for review. https://gerrit.wikimedia.org/r/203886
Change subject: service::node: fix the look-up of undefined variables ...................................................................... service::node: fix the look-up of undefined variables Some variables may not be defined when completing the template. Unfortunately for us, scope#lookupvar does not return nil, but 'undef' on such occasions (etiher as a string or symbol). This causes any possible if-guards to be evaluated as true, and consequently we end up with variables set to the string 'undef'. For instance, citoid's config in the beta cluster does not have a proxy set, but the configuration reads: proxy: undef which is clearly wrong. This patch translates such look-ups into empty strings, which represents perfectly-valid YAML. Bug: T95533 Change-Id: I9eab4f1627070e031c33ee4640ba146cdc9fd600 --- M modules/service/templates/node/config.yaml.erb 1 file changed, 18 insertions(+), 9 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/operations/puppet refs/changes/86/203886/1 diff --git a/modules/service/templates/node/config.yaml.erb b/modules/service/templates/node/config.yaml.erb index caa82cc..65bfe73 100644 --- a/modules/service/templates/node/config.yaml.erb +++ b/modules/service/templates/node/config.yaml.erb @@ -1,3 +1,16 @@ +<% +cvars = { + gelf_host => scope.lookupvar('service::configuration::logstash_host'), + gelf_port => scope.lookupvar('service::configuration::logstash_port'), + stat_host => scope.lookupvar('service::configuration::statsd_host'), + stat_port => scope.lookupvar('service::configuration::statsd_port'), + proxy => scope.lookupvar('service::configuration::http_proxy') +} + +cvars.keys.each do |k| + cvars[k] = '' if !cvars[k] or ['undef', ''].include? cvars[k].to_s +end +%> # Number of worker processes to spawn. # Set to 0 to run everything in a single process without clustering. # Use 'ncpu' to run as many workers as there are CPU units @@ -14,8 +27,8 @@ streams: # Use gelf-stream -> logstash - type: gelf - host: <%= scope.lookupvar('service::configuration::logstash_host') %> - port: <%= scope.lookupvar('service::configuration::logstash_port') %> + host: <%= cvars['gelf_host'] %> + port: <%= cvars['gel_port'] %> - type: file path: <%= @local_logfile %> level: info @@ -23,8 +36,8 @@ # Statsd metrics reporter metrics: type: statsd - host: <%= scope.lookupvar('service::configuration::statsd_host') %> - port: <%= scope.lookupvar('service::configuration::statsd_port') %> + host: <%= cvars['stat_host'] %> + port: <%= cvars['stat_port'] %> services: - name: <%= @title %> @@ -45,8 +58,4 @@ # to restrict to a particular domain, use: # cors: restricted.domain.org # URL of the outbound proxy to use (complete with protocol) - <% if scope.lookupvar('service::configuration::http_proxy') %> - proxy: <%= scope.lookupvar('service::configuration::http_proxy') %> - <% else %> - # proxy: http://my.proxy.org:8080 - <% end %> + proxy: <%= cvars['proxy'] %> -- To view, visit https://gerrit.wikimedia.org/r/203886 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I9eab4f1627070e031c33ee4640ba146cdc9fd600 Gerrit-PatchSet: 1 Gerrit-Project: operations/puppet Gerrit-Branch: production Gerrit-Owner: Mobrovac <mobro...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits