2019-09-05 15:48:41 +02:00
|
|
|
---
|
|
|
|
- name: install dependencies packages
|
|
|
|
apt:
|
2019-11-21 13:15:34 +01:00
|
|
|
name: '{{ packages }}'
|
|
|
|
vars:
|
|
|
|
packages:
|
|
|
|
- apt-transport-https
|
|
|
|
- python-requests
|
2019-09-05 15:48:41 +02:00
|
|
|
retries: 2
|
|
|
|
register: result
|
|
|
|
until: result is succeeded
|
|
|
|
tags: elasticsearch
|
|
|
|
|
|
|
|
- name: add repository key
|
|
|
|
apt_key:
|
|
|
|
url: https://artifacts.elastic.co/GPG-KEY-elasticsearch
|
|
|
|
retries: 2
|
|
|
|
register: result
|
|
|
|
until: result is succeeded
|
|
|
|
tags: elasticsearch
|
|
|
|
|
|
|
|
- name: add repository
|
|
|
|
apt_repository:
|
|
|
|
repo: deb https://artifacts.elastic.co/packages/7.x/apt stable main
|
|
|
|
tags: elasticsearch
|
|
|
|
|
|
|
|
- name: install package
|
|
|
|
apt:
|
|
|
|
name: elasticsearch
|
|
|
|
retries: 2
|
|
|
|
register: result
|
|
|
|
until: result is succeeded
|
|
|
|
tags: elasticsearch
|
|
|
|
|
2019-11-21 13:06:01 +01:00
|
|
|
- name: set heap size
|
|
|
|
lineinfile:
|
|
|
|
path: /etc/elasticsearch/jvm.options
|
|
|
|
regexp: '^-{{ item }}'
|
|
|
|
line: '-{{ item }}{{ elasticsearch_heap_size }}'
|
|
|
|
loop:
|
|
|
|
- Xms
|
|
|
|
- Xmx
|
|
|
|
notify: restart elasticsearch
|
|
|
|
tags: elasticsearch
|
|
|
|
|
2019-09-05 15:48:41 +02:00
|
|
|
- name: copy config file
|
|
|
|
copy:
|
|
|
|
content: '{{ elasticsearch_full_config|to_yaml }}'
|
|
|
|
dest: /etc/elasticsearch/elasticsearch.yml
|
|
|
|
owner: root
|
|
|
|
group: elasticsearch
|
|
|
|
mode: 0640
|
|
|
|
notify: restart elasticsearch
|
|
|
|
tags: elasticsearch
|
|
|
|
|
|
|
|
- name: enable and start service
|
|
|
|
systemd:
|
|
|
|
name: elasticsearch
|
|
|
|
state: started
|
|
|
|
enabled: true
|
|
|
|
tags: elasticsearch
|
2019-11-21 13:15:34 +01:00
|
|
|
|
|
|
|
- name: wait for api is available
|
|
|
|
wait_for:
|
|
|
|
port: 9200
|
|
|
|
timeout: 10
|
|
|
|
tags: elasticsearch
|
|
|
|
|
|
|
|
- name: copy index templates
|
|
|
|
elasticsearch_template:
|
|
|
|
name: '{{ item.key }}'
|
|
|
|
index_patterns: '{{ item.value.index_patterns }}'
|
|
|
|
settings: '{{ item.value.settings|default({}) }}'
|
|
|
|
mappings: '{{ item.value.mappings|default({}) }}'
|
|
|
|
no_log: true
|
|
|
|
loop: '{{ elasticsearch_index_templates|dict2items }}'
|
|
|
|
run_once: true
|
|
|
|
tags: elasticsearch
|