From 633140bebbc6ec8cf84f2630cc24526eb168d87f Mon Sep 17 00:00:00 2001 From: Arnaud SINAYS Date: Wed, 25 May 2022 16:51:36 +0200 Subject: [PATCH 1/2] haproxy_exporter: escape cnf_scrape_uri to avoid malformed strings --- manifests/haproxy_exporter.pp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/manifests/haproxy_exporter.pp b/manifests/haproxy_exporter.pp index 8fc531116..62b9ff278 100644 --- a/manifests/haproxy_exporter.pp +++ b/manifests/haproxy_exporter.pp @@ -90,7 +90,8 @@ default => undef, } - $options = "--haproxy.scrape-uri=\"${cnf_scrape_uri}\" ${extra_options}" + $scrape_uri_quoted = String($cnf_scrape_uri, '%p') + $options = "--haproxy.scrape-uri=${scrape_uri_quoted} ${extra_options}" prometheus::daemon { $service_name: install_method => $install_method, From 394dc3df37d73ee41103171841dc6ea36fdaa042 Mon Sep 17 00:00:00 2001 From: Arnaud SINAYS Date: Wed, 8 Jun 2022 10:47:40 +0200 Subject: [PATCH 2/2] haproxy_exporter: test for cnf_scrape_uri quote escaping --- spec/classes/haproxy_exporter_spec.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/classes/haproxy_exporter_spec.rb b/spec/classes/haproxy_exporter_spec.rb index bfb7a77f1..e30e29deb 100644 --- a/spec/classes/haproxy_exporter_spec.rb +++ b/spec/classes/haproxy_exporter_spec.rb @@ -52,6 +52,7 @@ end it { is_expected.to compile.with_all_deps } + it { is_expected.to contain_prometheus__daemon('haproxy_exporter').with('options' => "--haproxy.scrape-uri='#{value}' ") } end end