我写了一个 ansible 角色来安装 elasticsearch 多节点集群,问题是我为每种类型的节点(主节点、数据节点)都有一个配置文件。我在每个剧本中指定主机时遇到问题。
setup_elastic.yml
---
- hosts: all
become: yes
become_user: root
roles:
- elasticsearch
这是大师的配置文件:
---
- 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"]
数据节点的配置文件:
---
- 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"]
这是主要任务:
---
# 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
我应该怎么办 ?