Proper locations for ansible-elasticsearch variables

Greetings once again!

When working with the ansible-elasticsearch playbook (from https://github.com/elastic/ansible-elasticsearch), is it acceptable for all of the Ansible variables to be defined in the same file?

I’m using /root/.ansible/roles/elastic.elasticsearch/vars/main.yml as the single storehouse for the variables and parameters, and for some of them it seems to be working well. (Additional info: My template files from which the various configuration files are built include all of the standard templates that come with the playbook, and I have not deleted any of the playbook/github-supplied variables files.)

For example, I changed the default es_heap_size to 3g, and found that this value did indeed propagate to the destination Elasticsearch node’s jvm.options file Xms and Xmx lines.

However, if I try setting an es_config parameter (fair to call it a variable?), such as node.name, I’m not getting a similar propagation into the destination node’s elasticsearch.yml file. For instance,

es_config[‘node.name’]: babyyoda

doesn’t arrive at the destination, and node.name is set to the node’s IP address. I’ve tried variations such as putting the node name (babyyoda) in single or double quotes, to no effect. Do these parameters need to go into a different file? I’m not getting any squawks from Ansible about duplicate variable definitions being detected (the “duplicated dict key” warning), and I’m not seeing any errors related to the node.name parameter (using ansible-playbook -vvv).

Since I use the same playbooks to build more than one elastic stack, I use variables from inventory files. I set vars that are global to she stack in a stack group_vars. Then I set rack specific vars in a stack_rack group etc. Finally, if vars are needed for specific hosts, I use host_vars for those.

This lets me test the ansible build that will be used for production in test and qa stacks.

in the playbook elasticsearch.yml file I see this code:

{% if es_config['node.name'] is not defined %}
node.name: {{inventory_hostname}}
{% endif %}

That seems to say if you define node.name, then the template doesn't put any node.name line in the result, which would then let node.name default. That looks like a bug in the ansible example.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.