103 lines
2.5 KiB
YAML
103 lines
2.5 KiB
YAML
---
|
|
- name: setup elastic group
|
|
group:
|
|
name: "{{ elastic_grp }}"
|
|
state: "present"
|
|
|
|
- name: setup elastic user
|
|
user:
|
|
name: "{{ elastic_usr }}"
|
|
home: "{{ elastic_home }}"
|
|
group: "{{ elastic_grp }}"
|
|
groups:
|
|
- "{{ elastic_grp }}"
|
|
comment: Virtual Elastic User
|
|
shell: /bin/bash
|
|
state: present
|
|
system: yes
|
|
|
|
- name: setup ElasticSearch directories
|
|
file:
|
|
state: directory
|
|
path: "{{ item }}"
|
|
owner: "{{ elastic_usr }}"
|
|
group: "{{ elastic_grp }}"
|
|
mode: 0750
|
|
loop:
|
|
- "{{ elastic_path }}"
|
|
- "{{ elastic_home }}"
|
|
- "{{ elastic_data_location }}"
|
|
- "{{ elastic_logs_location }}"
|
|
|
|
- name: download ElasticSearch
|
|
unarchive:
|
|
src: "{{ elastic_source }}/elasticsearch-{{ elastic_version }}-{{ elastic_platform_suffix }}.tar.gz"
|
|
dest: "{{ elastic_path }}"
|
|
creates: "{{ elastic_inst }}"
|
|
remote_src: true
|
|
owner: "{{ elastic_usr }}"
|
|
group: "{{ elastic_grp }}"
|
|
mode: 0755
|
|
register: elastic_install
|
|
|
|
- name: copy bootstrap config
|
|
copy:
|
|
remote_src: true
|
|
src: "{{ elastic_inst }}/config"
|
|
dest: "{{ elastic_home }}"
|
|
owner: "{{ elastic_usr }}"
|
|
group: "{{ elastic_grp }}"
|
|
mode: 0755
|
|
when: elastic_install.changed
|
|
|
|
- name: configure ElasticSearch
|
|
template:
|
|
src: "opt/elastic/home/config/{{ item }}.j2"
|
|
dest: "{{ elastic_conf }}/{{ item }}"
|
|
owner: "{{ elastic_usr }}"
|
|
group: "{{ elastic_grp }}"
|
|
mode: 0644
|
|
loop:
|
|
- elasticsearch.yml
|
|
- jvm.options
|
|
|
|
- name: rollout elasticsearch http p12 certificate
|
|
copy:
|
|
content: "{{ elastic_cert_http_p12 }}"
|
|
dest: "{{ elastic_cert }}/http.p12"
|
|
owner: "{{ elastic_usr }}"
|
|
group: "{{ elastic_grp }}"
|
|
mode: 0600
|
|
|
|
- name: rollout elasticsearch transport p12 certificate
|
|
copy:
|
|
content: "{{ elastic_cert_transport_p12 }}"
|
|
dest: "{{ elastic_cert }}/transport.p12"
|
|
owner: "{{ elastic_usr }}"
|
|
group: "{{ elastic_grp }}"
|
|
mode: 0600
|
|
|
|
- name: configure max map count
|
|
sysctl:
|
|
name: vm.max_map_count
|
|
value: '262144'
|
|
state: present
|
|
|
|
- name: setup generic ElasticSearch link
|
|
file:
|
|
state: link
|
|
src: "{{ elastic_inst }}"
|
|
dest: "{{ elastic_link }}"
|
|
|
|
- name: setup ElasticSearch systemd unit
|
|
template:
|
|
src: etc/systemd/system/elasticsearch.service.j2
|
|
dest: /etc/systemd/system/elasticsearch.service
|
|
notify: restart elasticsearch
|
|
|
|
- name: enable elasticsearch systemd unit
|
|
systemd:
|
|
name: elasticsearch
|
|
enabled: yes
|
|
daemon_reload: yes
|
|
state: started |