From e5ebce01c6623bebce7cba292f611bf44055833b Mon Sep 17 00:00:00 2001 From: Stuart Warren Date: Tue, 29 Apr 2014 13:14:56 +0100 Subject: [PATCH] Added a "elasticsearch::customize" attribute file to customize the cookbook's default attributes Closes #208 Related: #112, #168, #178, #179, #180, #196, #208 --- README.markdown | 9 +++++++++ attributes/customize.rb | 9 +++++++++ attributes/default.rb | 3 +++ 3 files changed, 21 insertions(+) create mode 100644 attributes/customize.rb diff --git a/README.markdown b/README.markdown index bd371ae82..95cfffe94 100644 --- a/README.markdown +++ b/README.markdown @@ -261,6 +261,15 @@ END ssh ... "sudo chef-solo -N elasticsearch-wrapper-cookbook-test -j node.json" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +For customizing the default attributes, there's a `elasticsearch::customize` recipe, +which solves -- for the time being -- problems when over-riding the attributes. + +Create a `elasticsearch/attributes/customize.rb` file in your wrapper cookbook, +and place any attribute overrides there: + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~bash +echo "normal[:elasticsearch][:version] = '1.1.0'" > my-elasticsearch/attributes/customize.rb +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Nginx Proxy ----------- diff --git a/attributes/customize.rb b/attributes/customize.rb new file mode 100644 index 000000000..a5d4fb0f9 --- /dev/null +++ b/attributes/customize.rb @@ -0,0 +1,9 @@ +# Override the cookbook's default attributes in this file. +# +# Usually, you don't change this file directly, but you'll create a "elasticsearch/attributes/customize.rb" file +# in your wrapper cookbook and put the overrides in that file. +# +# The following shows how to override the Elasticsearch version and cluster name settings: +# +# normal[:elasticsearch][:version] = '1.1.0' +# normal[:elasticsearch][:cluster][:name] = 'my-cluster' diff --git a/attributes/default.rb b/attributes/default.rb index 5c8096eba..80aab2dcb 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -7,6 +7,9 @@ # node.default[:elasticsearch] ||= {} node.normal[:elasticsearch] ||= {} + +include_attribute 'elasticsearch::customize' + node.normal[:elasticsearch] = DeepMerge.merge(node.default[:elasticsearch].to_hash, node.normal[:elasticsearch].to_hash) node.normal[:elasticsearch] = DeepMerge.merge(node.normal[:elasticsearch].to_hash, settings.to_hash)