samples/ha_proxy.cfg.erb in consul-templaterb-1.9.8 vs samples/ha_proxy.cfg.erb in consul-templaterb-1.9.9

- old
+ new

@@ -2,11 +2,11 @@ # This template can be configure the following way with environment variables # Environment variables to filter services/instances # SERVICES_TAG_FILTER: basic tag filter for service (default HTTP) # INSTANCE_MUST_TAG: Second level of filtering (optional, default to SERVICES_TAG_FILTER) # INSTANCE_EXCLUDE_TAG: Exclude instances having the given tag (default: canary) -# EXCLUDE_SERVICES: comma-separated services to exclude (default: consul-agent-http,mesos-slave,mesos-agent-watcher) +# EXCLUDE_SERVICES: comma-separated services regexps to exclude (default: lbl7.*,netsvc-probe.*,consul-probed.*) # Environment variables to configure HaProxy # PORT0 : HaProxy main port (default to 8000) # PORT1 : HaProxy admin port (default to 8001) # HAPROXY_ADMIN_PORT: Port to listen # HAPROXY_ADMIN_USER_PASSWORD: User:Password to access to stats (default: none) @@ -15,11 +15,12 @@ service_tag_filter = ENV['SERVICES_TAG_FILTER'] || 'http' instance_must_tag = ENV['INSTANCE_MUST_TAG'] || service_tag_filter instance_exclude_tag = ENV['INSTANCE_EXCLUDE_TAG'] || 'canary' # Services to hide - services_blacklist = (ENV['EXCLUDE_SERVICES'] || 'consul-agent-http,mesos-slave,mesos-agent-watcher,mesos-exporter-slave').split(',') + services_blacklist_raw = (ENV['EXCLUDE_SERVICES'] || 'consul-agent-http,mesos-slave,mesos-agent-watcher,mesos-exporter-slave').split(',') + services_blacklist = services_blacklist_raw.map { |v| Regexp.new(v) } def compute_attributes(snode) w = 100 snode['Service']['Tags'].each do |tag| match = /^weight-([1-9][0-9])*$/.match(tag) @@ -33,10 +34,10 @@ end attributes = "#{attributes} weight #{w}" if w.positive? end backends = {} services(tag: service_tag_filter).each do |service_name, tags| - if !services_blacklist.include?(service_name) && tags.include?(instance_must_tag) + if !services_blacklist.any? {|r| r.match(service_name)} && tags.include?(instance_must_tag) the_backends = [] service(service_name, tag:'http').sort {|a,b| a['Node']['Node'] <=> b['Node']['Node'] }.each do |node| tags_of_instance = node['Service']['Tags'] if tags_of_instance.include?(instance_must_tag) && !tags_of_instance.include?(instance_exclude_tag) the_backends << node if node['Service']['Port'] \ No newline at end of file