forked from evolix/ansible-roles
76 lines
1.9 KiB
YAML
76 lines
1.9 KiB
YAML
---
|
|
|
|
- name: "User {{ elasticsearch_plugin_head_owner }} is present"
|
|
ansible.builtin.user:
|
|
name: "{{ elasticsearch_plugin_head_owner }}"
|
|
home: "{{ elasticsearch_plugin_head_home }}"
|
|
createhome: yes
|
|
system: yes
|
|
shell: /bin/false
|
|
|
|
- name: Head plugin is installed
|
|
block:
|
|
- name: Head repository is checked-out
|
|
ansible.builtin.git:
|
|
repo: "https://github.com/mobz/elasticsearch-head.git"
|
|
dest: "{{ elasticsearch_plugin_head_clone_dir }}"
|
|
clone: yes
|
|
tags:
|
|
- packages
|
|
|
|
- name: Create tmpdir
|
|
ansible.builtin.file:
|
|
dest: "{{ elasticsearch_plugin_head_tmp_dir }}"
|
|
state: directory
|
|
|
|
- name: NPM packages for head are installed
|
|
community.general.npm:
|
|
path: "{{ elasticsearch_plugin_head_clone_dir }}"
|
|
tags:
|
|
- packages
|
|
- npm
|
|
environment:
|
|
TMPDIR: "{{ elasticsearch_plugin_head_tmp_dir }}"
|
|
become_user: "{{ elasticsearch_plugin_head_owner }}"
|
|
become: true
|
|
|
|
- name: Elasticsearch HTTP/CORS are enabled
|
|
ansible.builtin.lineinfile:
|
|
dest: /etc/elasticsearch/elasticsearch.yml
|
|
line: "http.cors.enabled: true"
|
|
regexp: "^http.cors.enabled:"
|
|
insertafter: EOF
|
|
notify:
|
|
- restart elasticsearch
|
|
tags:
|
|
- elasticsearch
|
|
|
|
- name: Elasticsearch HTTP/CORS accepts all origins
|
|
ansible.builtin.lineinfile:
|
|
dest: /etc/elasticsearch/elasticsearch.yml
|
|
line: "http.cors.allow-origin: \"*\""
|
|
regexp: "^http.cors.allow-origin:"
|
|
insertafter: "http.cors.enabled"
|
|
notify:
|
|
- restart elasticsearch
|
|
tags:
|
|
- elasticsearch
|
|
|
|
- name: Install systemd unit
|
|
ansible.builtin.template:
|
|
src: elasticsearch-head.service.j2
|
|
dest: /etc/systemd/system/elasticsearch-head.service
|
|
tags:
|
|
- elasticsearch
|
|
- systemd
|
|
|
|
- name: Enable systemd unit
|
|
ansible.builtin.systemd:
|
|
name: elasticsearch-head
|
|
daemon_reload: yes
|
|
enabled: yes
|
|
state: started
|
|
tags:
|
|
- elasticsearch
|
|
- systemd
|