Created
October 8, 2013 13:57
-
-
Save gswallow/6885100 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Passing along a search query with string interpolation from a role doesn't work. | |
# Try setting it here, instead. | |
env = "chef_environment:#{node.chef_environment}" | |
if node['elasticsearch'].has_key?('discovery') | |
role = "role:#{node['elasticsearch']['discovery']['role']}" unless node['elasticsearch']['discovery']['role'].nil? | |
end | |
if node['elasticsearch'].has_key?('cluster') | |
cluster = "elasticsearch_cluster_name:#{node['elasticsearch']['cluster']['name']}" unless node['elasticsearch']['cluster']['name'].nil? | |
end | |
mark = [role, cluster].compact.join(" OR ") | |
raise "You need to set node['elasticsearch']['discovery']['role'] or node['elasticsearch']['cluster']['name'] before you can continue." if mark.nil? | |
query = "#{env} AND (#{mark})" | |
node.set['elasticsearch']['discovery']['search_query'] = query | |
include_recipe "elasticsearch::search_discovery" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment