Inital commit

This commit is contained in:
phil 2023-05-13 08:30:14 +02:00
commit 34c7873af9
8 changed files with 121 additions and 0 deletions

4
README.md Normal file
View file

@ -0,0 +1,4 @@
Opensearch
==========
Installation and configuration of [Opensearche](https://opensearch.org/).

8
defaults/main.yml Normal file
View file

@ -0,0 +1,8 @@
---
opensearch_apt_key_url: https://artifacts.opensearch.org/publickeys/opensearch.pgp
opensearch_apt_repo: https://artifacts.opensearch.org/releases/bundle/opensearch/2.x/apt stable main
opensearch_network_host: 127.0.0.1
opensearch_http_port: 9200
opensearch_attachment_max_size: 50
opensearch_plugin_update_script: update-opensearch-plugins
opensearch_monit_service: opensearch

10
handlers/main.yml Normal file
View file

@ -0,0 +1,10 @@
---
- name: reload monit
ansible.builtin.service:
name: monit
state: reloaded
- name: restart opensearch
ansible.builtin.service:
name: opensearch
state: restarted

10
meta/main.yml Normal file
View file

@ -0,0 +1,10 @@
galaxy_info:
author: systemausfall.org
description: Install and configure Opensearch
company: Sense.Lab e.V.
license: GPLv3
min_ansible_version: "2.9"
platforms:
- name: Debian
versions:
- bullseye

66
tasks/main.yml Normal file
View file

@ -0,0 +1,66 @@
---
- name: "Opensearch | Füge Schlüssel des Apt-Repositories hinzu"
ansible.builtin.apt_key:
url: "{{ opensearch_apt_key_url }}"
- name: "Opensearch | Füge Repository hinzu"
ansible.builtin.apt_repository:
repo: "deb {{ opensearch_apt_repo }}"
update_cache: true
- name: "Opensearch | Installiere deb-Paket"
ansible.builtin.apt:
name: opensearch
- name: "Opensearch | Installiere Ingest-Plugin"
ansible.builtin.command:
cmd: ./opensearch-plugin install ingest-attachment --batch
chdir: /usr/share/opensearch/bin/
creates: /usr/share/opensearch/plugins/ingest-attachment
become: true
become_user: opensearch
- name: "Opensearch | Kopiere Opensearch-Konfiguration"
ansible.builtin.template:
src: opensearch.yml.j2
dest: /etc/opensearch/opensearch.yml
mode: "0644"
- name: "Opensearch | Setze empfohlene Optionen"
ansible.builtin.replace:
path: /etc/opensearch/jvm.options
regexp: "{{ item.regexp }}"
replace: "{{ item.replace }}"
loop:
- regexp: '^-Xms[0-9]*g$'
replace: -Xms{{ (ansible_memtotal_mb / 1024 * 0.5) | round | int }}g
- regexp: '^-Xmx[0-9]*g$'
replace: -Xmx{{ (ansible_memtotal_mb / 1024 * 0.5) | round | int }}g
notify: restart opensearch
- name: "Opensearch | Starte Opensearch-Dienst"
ansible.builtin.systemd:
name: opensearch
enabled: true
state: started
daemon_reload: true
- name: "Opensearch | Richte Monit-Überwachung ein"
ansible.builtin.template:
src: opensearch.monit.j2
dest: /etc/monit/conf-enabled/opensearch
mode: "0644"
notify: reload monit
- name: "Opensearch | Kopiere Update-Skript"
ansible.builtin.template:
src: update-opensearch-plugins.j2
dest: "/usr/local/bin/{{ opensearch_plugin_update_script }}"
mode: "0755"
- name: "Opensearch | Kopiere DPKG-Hook"
ansible.builtin.template:
src: 72opensearch-updates.j2
dest: /etc/apt/apt.conf.d/72opensearch-updates
mode: "0644"

View file

@ -0,0 +1,5 @@
# {{ ansible_managed }}
# Neuinstallation der Plugins
DPkg::Pre-Invoke {"/usr/local/bin//{{ opensearch_plugin_update_script }} purge";};
DPkg::Post-Invoke {"/usr/local/bin//{{ opensearch_plugin_update_script }} install";};

View file

@ -0,0 +1,7 @@
# {{ ansible_managed }}
check process {{ opensearch_monit_service }} with pidfile /run/opensearch/opensearch.pid
start program = "/usr/sbin/service opensearch start"
stop program = "/usr/sbin/service opensearch stop"
if failed host {{ opensearch_network_host }} port {{ opensearch_http_port }} for 3 cycles then restart
if 5 restarts within 5 cycles then timeout

View file

@ -0,0 +1,11 @@
# {{ ansible_managed }}
path.data: /var/lib/opensearch
path.logs: /var/log/opensearch
network.host: {{ opensearch_network_host }}
http.port: {{ opensearch_http_port }}
discovery.type: single-node
compatibility.override_main_response_version: true
plugins.security.disabled: true