From 43fe1b4891fb2ce451a719801fc42e00315456b5 Mon Sep 17 00:00:00 2001 From: Jaime Fullaondo Date: Thu, 7 Apr 2016 16:58:58 -0400 Subject: [PATCH] [http_check] fixing variable reassignment, and template. [http_check] fixing template. [http_check] fixing yaml alignment. --- manifests/integrations/http_check.pp | 4 ++- templates/agent-conf.d/http_check.yaml.erb | 34 +++++++++++----------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/manifests/integrations/http_check.pp b/manifests/integrations/http_check.pp index 0da8e325..5a8750ff 100644 --- a/manifests/integrations/http_check.pp +++ b/manifests/integrations/http_check.pp @@ -90,7 +90,7 @@ ) inherits datadog_agent::params { if $instances == undef { - $instances = [{ + $_instances = [{ 'url' => $url, 'username' => $username, 'password' => $password, @@ -104,6 +104,8 @@ 'tags' => $tags, 'contact' => $contact, }] + } else { + $_instances = $instances } file { "${datadog_agent::params::conf_dir}/http_check.yaml": diff --git a/templates/agent-conf.d/http_check.yaml.erb b/templates/agent-conf.d/http_check.yaml.erb index d63ad134..fb3683f4 100644 --- a/templates/agent-conf.d/http_check.yaml.erb +++ b/templates/agent-conf.d/http_check.yaml.erb @@ -1,52 +1,52 @@ init_config: instances: -<%- (Array(@instances)).each do |instance| -%> - - name: <%= instance['name'] %> - url: <%= instance['url'] %> +<%- (Array(@_instances)).each do |instance| -%> + - name: <%= instance['name'] %> + url: <%= instance['url'] %> <% if instance['timeout'] -%> - timeout: <%= instance['timeout'] %> + timeout: <%= instance['timeout'] %> <% end -%> <% if instance['username'] -%> - username: <%= instance['username'] %> + username: <%= instance['username'] %> <% end -%> <% if instance['password'] -%> - password: <%= instance['password'] %> + password: <%= instance['password'] %> <% end -%> <% if instance['threshold'] -%> - threshold: <%= instance['threshold'] %> + threshold: <%= instance['threshold'] %> <% end -%> <% if instance['window'] -%> - window: <%= instance['window'] %> + window: <%= instance['window'] %> <% end -%> <% if instance['include_content'] -%> - include_content: <%= instance['include_content'] %> + include_content: <%= instance['include_content'] %> <% end -%> <% if instance['collect_response_time'] -%> - collect_response_time: <%= instance['collect_response_time'] %> + collect_response_time: <%= instance['collect_response_time'] %> <% end -%> - disable_ssl_validation: <%= instance['disable_ssl_validation'] %> + disable_ssl_validation: <%= instance['disable_ssl_validation'] %> <% if instance['headers'] and ! instance['headers'].empty? -%> - headers: + headers: <%- Array(instance['headers']).each do |header| -%> <%- if header != '' -%> - <%= header %> + <%= header %> <%- end -%> <%- end -%> <% end -%> <% if instance['tags'] and ! instance['tags'].empty? -%> - tags: + tags: <%- Array(instance['tags']).each do |tag| -%> <%- if tag != '' -%> - - <%= tag %> + - <%= tag %> <%- end -%> <%- end -%> <% end -%> <% if instance['contacts'] and ! instance['contacts'].empty? -%> - notify: + notify: <%- Array(instance['contacts']).each do |contact| -%> <%- if contact != '' -%> - - <%= contact %> + - <%= contact %> <%- end -%> <%- end -%> <% end -%>