【发布时间】:2020-05-24 21:57:52
【问题描述】:
我正在尝试使用官方 Elastic Ansible 角色 elastic.elasticsearch 在 Ansible 上配置 Elasticsearch 集群。我为我的 AWS 实例设置了 Ansible 塔和动态清单。我标记了我的实例并将它们全部分组在 tag_Group_Elasticsearch 中。这是 Ansible 代码:
hosts: tag_Group_Elasticsearch
roles:
- role: elastic.elasticsearch
vars:
es_heap_size: "2g"
es_config:
network.host: 0.0.0.0
cluster.name: "prod-cluster"
cluster.initial_master_nodes: "tag_Group_Elasticsearch"
discovery.seed_hosts: "tag_Group_Elasticsearch"
http.port: 9200
node.master: true
bootstrap.memory_lock: false
es_plugins:
- plugin: ingest-attachment
因此,当我想在角色中使用该组时,它在主持该剧的一部分时效果很好。它很好地解决并适用于组中的所有主机。但是当我想在 es_config 变量中使用它时,它不会解析为主机名,它只是将它作为字符串传递,因此,elasticsearch 集群失败。
这是我在集群成员的 elasticsearch.yml 中得到的:
cluster.initial_master_nodes: tag_Group_Elasticsearch
discovery.seed_hosts: tag_Group_Elasticsearch
我需要的是:
cluster.initial_master_nodes: "192.168.x.x, 192.168.x.x, 192.168.x.x "
discovery.seed_hosts: "192.168.x.x, 192.168.x.x, 192.168.x.x"
我无法在 cluster.initial_master_nodes 和 discovery.seed_hosts 中手动添加主机名,因为我的 Elasticsearch 集群是基于 AWS 自动缩放组构建的,并且我的主机是动态的...
干杯, 德拉甘
【问题讨论】:
-
查看ansible special vars 并搜索
groups。然后查看ansible filters 并搜索join
标签: elasticsearch ansible autoscaling ansible-inventory ansible-tower