Ansible/playbook/linux/elastic/config-elasticsearch.yml

99 lines
2.6 KiB
YAML
Raw Normal View History

# This will work on a new install.
# If any changes are needed to the cluster name on an existing install add another function
- name: Config - cluster.name 'logging-dev'
become: true
lineinfile:
path: /etc/elasticsearch/elasticsearch.yml
regex: '^cluster.name'
insertafter: '#cluster.name: my-application'
line: 'cluster.name: logging-dev'
backup: yes
# We define the name of the host we are working on
- name: Config - node.name
become: true
lineinfile:
path: /etc/elasticsearch/elasticsearch.yml
regex: '^node.name'
insertafter: '#node.name: node-1'
line: "node.name: dev-data-01"
- name: Config - network.host
become: true
lineinfile:
path: /etc/elasticsearch/elasticsearch.yml
regexp: 'network.host:'
insertafter: '#network.host:'
line: 'network.host: {{ ansible_eno1.ipv4.address }}'
- name: Config - transport.host
become: true
lineinfile:
path: /etc/elasticsearch/elasticsearch.yml
regexp: 'transort.host:'
#insertafter: 'http.port: 9200'
line: 'transport.host: localhost'
state: present
#backrefs: yes
- name: Config - transport.tcp.port
become: true
lineinfile:
path: /etc/elasticsearch/elasticsearch.yml
regexp: 'transport.tcp.port:'
#insertafter: 'transport.host: localhost'
line: 'transport.tcp.port: 9300'
state: present
backrefs: yes
- name: Config - node.master
become: true
lineinfile:
path: /etc/elasticsearch/elasticsearch.yml
regexp: 'node.master:'
insertafter: 'node.name:'
line: 'node.master: true'
state: present
backrefs: yes
- name: Config - node.data
become: true
lineinfile:
path: /etc/elasticsearch/elasticsearch.yml
regexp: 'node.data:'
insertafter: 'node.master:'
line: 'node.data: true'
state: present
backrefs: yes
# Allow 9200 so we can access it over the network
- name: Allow port 9200 though UFW
become: true
ufw:
rule: allow
port: 9200
#name: ElasticSearch
- name: Allow port 9300 though UFW
become: true
ufw:
rule: allow
port: 9300
- name: Service reload daemon
become: true
systemd:
daemon_reload: yes
- name: systemd - enable ElasticSearch on startup
become: true
systemd:
name: elasticsearch
enabled: yes
- name: systemd - restart ElasticSearch service
become: true
systemd:
name: elasticsearch
state: restarted