feat: split tasks
This commit is contained in:
parent
c867790a8c
commit
033627595d
5 changed files with 82 additions and 77 deletions
21
tasks/config.yml
Normal file
21
tasks/config.yml
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
---
|
||||||
|
- 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
|
||||||
|
|
||||||
|
- 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
|
11
tasks/data.yml
Normal file
11
tasks/data.yml
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
---
|
||||||
|
- 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
|
|
@ -1,78 +1,5 @@
|
||||||
---
|
---
|
||||||
- name: install dependencies packages
|
- import_tasks: packages.yml
|
||||||
apt:
|
- import_tasks: config.yml
|
||||||
name: '{{ packages }}'
|
- import_tasks: service.yml
|
||||||
vars:
|
- import_tasks: data.yml
|
||||||
packages:
|
|
||||||
- apt-transport-https
|
|
||||||
- python-requests
|
|
||||||
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
|
|
||||||
|
|
||||||
- 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
|
|
||||||
|
|
||||||
- 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
|
|
||||||
|
|
||||||
- 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
|
|
||||||
|
|
33
tasks/packages.yml
Normal file
33
tasks/packages.yml
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
---
|
||||||
|
- name: install dependencies packages
|
||||||
|
apt:
|
||||||
|
name: '{{ packages }}'
|
||||||
|
vars:
|
||||||
|
packages:
|
||||||
|
- apt-transport-https
|
||||||
|
- python-requests
|
||||||
|
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
|
13
tasks/service.yml
Normal file
13
tasks/service.yml
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
---
|
||||||
|
- name: enable and start service
|
||||||
|
systemd:
|
||||||
|
name: elasticsearch
|
||||||
|
state: started
|
||||||
|
enabled: true
|
||||||
|
tags: elasticsearch
|
||||||
|
|
||||||
|
- name: wait for api is available
|
||||||
|
wait_for:
|
||||||
|
port: 9200
|
||||||
|
timeout: 10
|
||||||
|
tags: elasticsearch
|
Loading…
Add table
Add a link
Reference in a new issue