---
- hosts: elk
tasks:
- name: yum install java
yum:
name: java-1.8.0-openjdk
state: installed
- name: install the elasticsearch
yum:
name: elasticsearch
state: installed
- lineinfile:
path: /etc/elasticsearch/elasticsearch.yml
regexp: 'cluster.name:'
line: 'cluster.name: myelk'
- lineinfile:
path: /etc/elasticsearch/elasticsearch.yml
regexp: 'network.host:'
line: 'network.host: 0.0.0.0'
- lineinfile:
path: /etc/elasticsearch/elasticsearch.yml
regexp: 'discovery.zen.ping.unicast.hosts:'
line: 'discovery.zen.ping.unicast.hosts: ["byes1","byes2","byes3"]'
- lineinfile:
path: /etc/elasticsearch/elasticsearch.yml
regexp: 'node.name: '
line: 'node.name: byes1'
when: ansible_hostname == "byes1"
- lineinfile:
path: /etc/elasticsearch/elasticsearch.yml
regexp: 'node.name: '
line: 'node.name: byes2'
when: ansible_hostname == "byes2"
- lineinfile:
path: /etc/elasticsearch/elasticsearch.yml
regexp: 'node.name: '
line: 'node.name: byes3'
when: ansible_hostname == "byes3"
- lineinfile:
path: /etc/elasticsearch/elasticsearch.yml
regexp: 'node.name: '
line: 'node.name: byes4'
when: ansible_hostname == "byes4"
- lineinfile:
path: /etc/elasticsearch/elasticsearch.yml
regexp: 'node.name: '
line: 'node.name: byes5'
when: ansible_hostname == "byes5"
- service:
name: elasticsearch
state: restarted
enabled: yes
网友评论