From 1cac4eb8d40ccb2d534f030c3329a456e03404bd Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Wed, 16 Sep 2020 17:54:38 +0100 Subject: [PATCH] Add brackets around IPv6 addresses --- cookbooks/prometheus/resources/exporter.rb | 6 +++++- cookbooks/prometheus/templates/default/prometheus.yml.erb | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/cookbooks/prometheus/resources/exporter.rb b/cookbooks/prometheus/resources/exporter.rb index c75248f99..08c0e03b7 100644 --- a/cookbooks/prometheus/resources/exporter.rb +++ b/cookbooks/prometheus/resources/exporter.rb @@ -77,7 +77,11 @@ action_class do end def listen_address - "#{node[:prometheus][:address]}:#{new_resource.port}" + if node[:prometheus][:mode] == "wireguard" + "[#{node[:prometheus][:address]}]:#{new_resource.port}" + else + "#{node[:prometheus][:address]}:#{new_resource.port}" + end end def service_name diff --git a/cookbooks/prometheus/templates/default/prometheus.yml.erb b/cookbooks/prometheus/templates/default/prometheus.yml.erb index 66051b622..46d241905 100644 --- a/cookbooks/prometheus/templates/default/prometheus.yml.erb +++ b/cookbooks/prometheus/templates/default/prometheus.yml.erb @@ -16,7 +16,7 @@ scrape_configs: static_configs: <% targets.each do |target| -%> - targets: - - <%= target[:address] %> + - "<%= target[:address] %>" labels: instance: <%= target[:name].split(".").first %> <% end -%> -- 2.43.2