Move to version 1.6.1
[sdc.git] / sdc-os-chef / sdc-init-elasticsearch / chef-repo / cookbooks / init-sdc-elasticsearch / recipes / ES_3_create_monitoring_template.rb
index 02b20f8..685b468 100644 (file)
@@ -1,8 +1,11 @@
+# Get the first es node in the list
+es_node =  node['Nodes']['ES'].first
+
 ruby_block "check_ElasticSearch_Cluster_Health" do
     block do
       #tricky way to load this Chef::Mixin::ShellOut utilities
       Chef::Resource::RubyBlock.send(:include, Chef::Mixin::ShellOut)
-      curl_command = "http://#{node['Nodes']['ES']}:9200/_cluster/health?pretty=true"
+      curl_command = "http://#{es_node}:9200/_cluster/health?pretty=true"
       resp = Net::HTTP.get_response URI.parse(curl_command)
       stat = JSON.parse(resp.read_body)['status']
 
@@ -48,6 +51,6 @@ bash "create monitoring mapping" do
                                }
                        },
                        "aliases": { "last_3_months": {} }
-               }' http://#{node['Nodes']['ES']}:9200/_template/monitoring_template
+               }' http://#{es_node}:9200/_template/monitoring_template
        EOH
 end