Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Override elasticsearch.yml #482

Closed
imewish opened this issue Jul 4, 2016 · 8 comments
Closed

Override elasticsearch.yml #482

imewish opened this issue Jul 4, 2016 · 8 comments

Comments

@imewish
Copy link

imewish commented Jul 4, 2016

How can i override the default elasticsearch.ym file with custom file in my wrapper cookbook?

@martinb3
Copy link
Contributor

martinb3 commented Jul 4, 2016

Hello! You'd use these attributes on elasticsearch_configure:

attribute(:template_elasticsearch_yml, kind_of: String, default: 'elasticsearch.yml.erb')
attribute(:cookbook_elasticsearch_yml, kind_of: String, default: 'elasticsearch')

e.g.:

elasticsearch_configure 'default' do
  cookbook_elasticsearch_yml 'mycookbook'
  template_elasticsearch_yml 'myfilename'
end

Hope this helps!

@martinb3 martinb3 closed this as completed Jul 4, 2016
@imewish
Copy link
Author

imewish commented Jul 5, 2016

Hi Martin,

Thanks for the reply. I have tried the above settings.

So in my custom elasticserach.yml file, i have two extra configs, for node.data and node.master

# ------------------------------------ Node ------------------------------------`
#
<%= print_value(@config, 'node.name') -%>
<%= print_value(@config, 'node.data') -%>
<%= print_value(@config, 'node.master') -%>
<%= print_value(@config, 'node.max_local_storage_nodes') -%>

on the chef run with this settings that extra two configs are removed and set to the defaults.

do i need to set values for the newly added configs as attribute anywhere?

@martinb3
Copy link
Contributor

martinb3 commented Jul 5, 2016

Hi @imewish -- where are you setting those values for node.data and node.master currently? There are some examples in the README.md of different ways to set configuration values, but I'd like to understand what you've already done. Maybe you can show us how you're setting those extra values now?

Also, it's worth noting that, by default, any configuration items added using elasticsearch_configure are printed in elasticsearch.yml. You don't need a custom template to do this.

@imewish
Copy link
Author

imewish commented Jul 5, 2016

Hi,

I wanted to set the node.data,node.master as a node attribute. not in the recipe. As the examples shows in
README.md its possible through the recipe.

@martinb3
Copy link
Contributor

martinb3 commented Jul 5, 2016

Can you show us what you're doing or what you've tried?

@imewish
Copy link
Author

imewish commented Jul 5, 2016

So ,

What i am trying to do is,

I have created a wrapper cookbook by adding elasticsearch as dependency(to be resolved by berkshlef).
All the installation went fine and elasticsearch is running fine. Now im in need to reconfigure elasticsearch as per our needs. My idea was to replace the default elasticsearch.yml file with custom one and set the values as attributes(that was bad idea). So now my question is, is it possible to add additional config settings(node.master,http.enabled etc) to elasticsearch.yml as a node/role attribute without setting it on cookbook?

NB: Im a beginner in chef. sorry if my explanation is not clear. :)

@martinb3
Copy link
Contributor

martinb3 commented Jul 5, 2016

@imewish No problem -- there are some examples in the README.md.

You could easily do something like this:

elasticsearch_configure 'elasticsearch' do
    allocated_memory '512m'
    configuration ({
      'cluster.name' => node['foo']['cluster_name']
      'node.name' => node['foo']['node_name']
      'http.port' => node['foo']['http_port']
    })
end

This is a library cookbook, so it's exposing primitives you can use, but it won't do what you want with node attributes unless you write something like the above. HTH.

@imewish
Copy link
Author

imewish commented Jul 5, 2016

Alright. Thanks for the Help :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants