feat: add elasticsearch

This commit is contained in:
VC
2024-07-05 11:53:37 +02:00
parent fbe86a8d77
commit f9c9a00981
8 changed files with 130 additions and 0 deletions

7
elasticsearch.yml Normal file
View File

@@ -0,0 +1,7 @@
---
- name: Deploy elasticsearch
hosts: elasticsearchservers
diff: true
roles:
- elasticsearch

View File

@@ -85,6 +85,10 @@ garageservers:
garagegw1.dmz.mateu.be: garagegw1.dmz.mateu.be:
garage_bck_cluster: garage_bck_cluster:
elasticsearchservers:
hosts:
es1.dmz.mateu.be:
nut: nut:
children: children:
nut_server: nut_server:

View File

@@ -0,0 +1,6 @@
---
elasticsearch_key_url: "https://artifacts.elastic.co/GPG-KEY-elasticsearch"
elasticsearch_key_path: "/usr/share/keyrings/elasticsearch.asc"
elasticsearch_data_dir: /srv/elasticsearch

View File

@@ -0,0 +1,6 @@
---
- name: Restart elasticsearch
ansible.builtin.service:
name: elasticsearch
state: restarted

View File

@@ -0,0 +1,50 @@
---
- name: Install prereq
ansible.builtin.package:
name: openjdk-17-jre-headless
state: present
- name: Get elasticsearch key
ansible.builtin.get_url:
url: "{{ elasticsearch_key_url }}"
dest: "{{ elasticsearch_key_path }}"
force: true
mode: 0644
- name: Set elasticsearch source repo
ansible.builtin.copy:
content: "deb [signed-by={{ elasticsearch_key_path }}] https://artifacts.elastic.co/packages/7.x/apt stable main"
dest: /etc/apt/sources.list.d/elasticsearch.list
mode: '0644'
- name: Install elasticsearch
ansible.builtin.apt:
name: elasticsearch
state: present
update_cache: true
- name: Create elasticsearch dir
ansible.builtin.file:
path: "{{ elasticsearch_data_dir }}"
state: directory
owner: elasticsearch
group: elasticsearch
mode: '2750'
- name: Put elasticsearch config file
ansible.builtin.template:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
mode: '0644'
notify:
- Restart elasticsearch
loop:
- {src: elasticsearch.yml.j2, dest: /etc/elasticsearch/elasticsearch.yml}
- {src: elasticsearch.j2, dest: /etc/default/elasticsearch}
- name: Starts and enables elasticsearch
ansible.builtin.service:
name: elasticsearch
state: started
enabled: true

View File

@@ -0,0 +1,52 @@
################################
# Elasticsearch
################################
# Elasticsearch home directory
#ES_HOME=/usr/share/elasticsearch
# Elasticsearch Java path
#ES_JAVA_HOME=
# Elasticsearch configuration directory
# Note: this setting will be shared with command-line tools
ES_PATH_CONF=/etc/elasticsearch
# Elasticsearch PID directory
#PID_DIR=/var/run/elasticsearch
# Additional Java OPTS
ES_JAVA_OPTS="-Xms1g -Xmx1g"
# Configure restart on package upgrade (true, every other setting will lead to not restarting)
#RESTART_ON_UPGRADE=true
################################
# Elasticsearch service
################################
# SysV init.d
#
# The number of seconds to wait before checking if Elasticsearch started successfully as a daemon process
ES_STARTUP_SLEEP_TIME=5
################################
# System properties
################################
# Specifies the maximum file descriptor number that can be opened by this process
# When using Systemd, this setting is ignored and the LimitNOFILE defined in
# /usr/lib/systemd/system/elasticsearch.service takes precedence
#MAX_OPEN_FILES=65535
# The maximum number of bytes of memory that may be locked into RAM
# Set to "unlimited" if you use the 'bootstrap.memory_lock: true' option
# in elasticsearch.yml.
# When using systemd, LimitMEMLOCK must be set in a unit file such as
# /etc/systemd/system/elasticsearch.service.d/override.conf.
#MAX_LOCKED_MEMORY=unlimited
# Maximum number of VMA (Virtual Memory Areas) a process can own
# When using Systemd, this setting is ignored and the 'vm.max_map_count'
# property is set at boot time in /usr/lib/sysctl.d/elasticsearch.conf
#MAX_MAP_COUNT=262144

View File

@@ -0,0 +1,4 @@
network.host: 0.0.0.0
discovery.type: single-node
path.data: {{ elasticsearch_data_dir }}
path.logs: /var/log/elasticsearch

View File

@@ -24,3 +24,4 @@
- import_playbook: ftp.yml - import_playbook: ftp.yml
- import_playbook: garage.yml - import_playbook: garage.yml
- import_playbook: peertube.yml - import_playbook: peertube.yml
- import_playbook: elasticsearch.yml