0

I am trying to use "elasticsearch/cookbook-elasticsearch" cookbook for with my wrapper cookbook. I want to override following default attributes from cookbook-elasticsearch in my wrapper cookbook.

default.elasticsearch[:rpm_url] = "https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.90.12.noarch.rpm"
default.elasticsearch[:rpm_sha] = "ab7ea2e00d8f1b73642e3ea44d9647b11e6b0b96"

Cookbook : https://github.com/elasticsearch/cookbook-elasticsearch

How do I do this in my-elasticsearch cookbook ?

cat site-cookbooks/my-elasticsearch/attributes/default.rb

override.elasticsearch[:rpm_url] = "https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.4.4.noarch.rpm"
override.elasticsearch[:rpm_sha] = "ec8b41c54a6d897479645b2507476e0824bc71db"

is this correct one ?

I want to use this cookbook for chef 10

any help

roy
  • 6,344
  • 24
  • 92
  • 174
  • Beware Chef 10 is now very old.... Your answer is to take advantage of attribute precedence and set either "normal" or "override" attributes in the wrapper cookbook. – Mark O'Connor Feb 23 '15 at 22:44
  • something like this override.elasticsearch[:rpm_url] ? – roy Feb 23 '15 at 22:56

1 Answers1

1

To add information to @mark-oconnor comment:

Documentation about attributes in chef 10.

Recommended notation would be override['elasticsearch']['rpm_url'] = "new_value" the method and symbol way to access attributes have been problematic in the past.

As the cookbook loading order in chef 10 is not always clearly predictable you have to use override level to ensure the correct value is used when compîling recipes.


Edit after comments:

In the elasticsearch cookbook in version 0.3.13 the default recipe install from tarball.

If you wish to use a packaged install you have to call the corresponding recipe before the default, as in the default recipe there's a guard to not install tarball if elasticsearch is already installed.

The correct recipe in wrapper cookbook for this particular case is:

include_recipe 'elasticsearch::rpm' # Take the overriden attributes and install package
include_recipe 'elasticsearch' # no need to ::default, if omitted it's the recipe loaded
Tensibai
  • 15,557
  • 1
  • 37
  • 57
  • I tried this but didnt work. It installed version 0.90.12.noarch.rpm instead of 1.4.4.noarch.rpm – roy Feb 24 '15 at 23:00
  • What is your node runlist ? As I said it's not always predictable in chef 10. Do you wrap with include_recipe ? – Tensibai Feb 25 '15 at 07:07
  • my runlist is my-elasticsearch and in my-elasticsearch/recipes/default.rb I have include_recipe 'elasticsearch::default' – roy Feb 25 '15 at 14:19
  • which version of the elasticsearch cookbook are you using ? (on the last one (0.3.13) I don't even get how it could download a rpm and not a .tar.gz file). – Tensibai Feb 25 '15 at 14:59
  • Ok, I got it, if you don't want to use the tarball install an use rpm install you have to `include_recipe elasticsearch::rpm` before `include_recipe elasticsearch::default`. The elasticsearch deafult recipe will install from tarball unless there's already a package install done (i.e another package recipe called) – Tensibai Feb 25 '15 at 15:48
  • I have started on fresh node with this https://gist.github.com/anonymous/8d63d99232317024ef7b but now its not even installing elasticsearch. what I am missing here ? – roy Feb 26 '15 at 17:01
  • @roy Without the log from the chef run, I can't tell what's wrong – Tensibai Feb 26 '15 at 17:34
  • okit looks like now its installing, but curl -s 'http://localhost:9200' returning version : 0.90.12 and rpm -qa | grep elasticsearch returning elasticsearch-1.4.4-1.noarch – roy Feb 26 '15 at 18:45
  • You diffuse two ways to install it, the service has not been restarted in-between so you still have the old version live. (restart from fresh box when retrying recipes, you'll save time shaving yacks that won't appear in real cases) – Tensibai Feb 26 '15 at 20:10
  • Finally got everything correct after hitting the wall few time. thanks for help – roy Feb 26 '15 at 20:12