I wrote an ansible role to install elasticsearch multi node cluster, the problème is that i have a configuration files for each type of node (Master, Data).I have a problem to specify the host in each playbook.
setup_elastic.yml
---
- hosts: all
become: yes
become_user: root
roles:
- elasticsearch
and here is the config file for masters:
---
- name: config elasticsearch master
blockinfile:
path: /etc/elasticsearch/elasticsearch.yml
block: |
cluster.name: lamedicale4
node.master: true
node.data: false
node.name: ${HOSTNAME}
bootstrap.mlockall: true
path.data: /data/elasticsearch
path.logs: /logs/elasticsearch
discovery.zen.minimum_master_nodes: 2
discovery.zen.ping.multicast.enabled: false
discovery.zen.ping.unicast.hosts : ["172.31.36.229","172.31.44.124"]
config file for data nodes:
---
- name: config elasticsearch data nodes
blockinfile:
path: /etc/elasticsearch/elasticsearch.yml
block: |
cluster.name: lamedicale4
node.master: false
node.data: true
node.name: ${HOSTNAME}
bootstrap.mlockall: true
path.data: /data/elasticsearch
path.logs: /logs/elasticsearch
discovery.zen.minimum_master_nodes: 2
discovery.zen.ping.multicast.enabled: false
discovery.zen.ping.unicast.hosts : ["172.31.36.229","172.31.44.124"]
and here is the main tasks:
---
# tasks file for /etc/ansible/roles/elastissearch
- import_tasks: install_java_jdk.yml
- import_tasks: install_elasticsearch.yml
- import_tasks: clear_file.yml
- import_tasks: directory_data_log_elastic.yml
- include_tasks: config_elasticsearch_master.yml
- include_tasks: config_elasticsearch_data.yml
- import_tasks: reload_restart_elasticsearch.yml
what should I do ?