From 0e083996e47246dc7d13179588e5e5ce3a5e1586 Mon Sep 17 00:00:00 2001 From: phil Date: Sat, 13 May 2023 08:35:32 +0200 Subject: [PATCH] Include external opensearch role --- tasks/opensearch.yml | 70 +------------------------- templates/72opensearch-updates.j2 | 5 -- templates/opensearch.monit.j2 | 7 --- templates/opensearch.yml | 11 ---- templates/update-opensearch-plugins.j2 | 35 ------------- 5 files changed, 2 insertions(+), 126 deletions(-) delete mode 100644 templates/72opensearch-updates.j2 delete mode 100644 templates/opensearch.monit.j2 delete mode 100644 templates/opensearch.yml delete mode 100644 templates/update-opensearch-plugins.j2 diff --git a/tasks/opensearch.yml b/tasks/opensearch.yml index 536d022..6928092 100644 --- a/tasks/opensearch.yml +++ b/tasks/opensearch.yml @@ -1,53 +1,7 @@ --- -- 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 - 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 | Konfiguriere Dienst-Adresse" ansible.builtin.shell: - cmd: rbenv exec bundle exec rails r "Setting.set('es_url', 'http://{{ opensearch.network_host }}:{{ opensearch.http_port }}')" + cmd: rbenv exec bundle exec rails r "Setting.set('es_url', 'http://{{ opensearch_network_host }}:{{ opensearch_http_port }}')" chdir: "{{ zammad_home }}" environment: RAILS_ENV: production @@ -83,29 +37,9 @@ - name: "Opensearch | Konfiguriere Datei-Größen" ansible.builtin.shell: - cmd: rbenv exec bundle exec rails r "Setting.set('es_attachment_max_size_in_mb', {{ opensearch.attachment_max_size }})" + cmd: rbenv exec bundle exec rails r "Setting.set('es_attachment_max_size_in_mb', {{ opensearch_attachment_max_size }})" chdir: "{{ zammad_home }}" environment: RAILS_ENV: production become: true become_user: "{{ zammad_user }}" - -- 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" - \ No newline at end of file diff --git a/templates/72opensearch-updates.j2 b/templates/72opensearch-updates.j2 deleted file mode 100644 index bdf3334..0000000 --- a/templates/72opensearch-updates.j2 +++ /dev/null @@ -1,5 +0,0 @@ -# {{ 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";}; diff --git a/templates/opensearch.monit.j2 b/templates/opensearch.monit.j2 deleted file mode 100644 index c9eefff..0000000 --- a/templates/opensearch.monit.j2 +++ /dev/null @@ -1,7 +0,0 @@ -# {{ 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 diff --git a/templates/opensearch.yml b/templates/opensearch.yml deleted file mode 100644 index f302478..0000000 --- a/templates/opensearch.yml +++ /dev/null @@ -1,11 +0,0 @@ -# {{ 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 diff --git a/templates/update-opensearch-plugins.j2 b/templates/update-opensearch-plugins.j2 deleted file mode 100644 index b00a65a..0000000 --- a/templates/update-opensearch-plugins.j2 +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh -# {{ ansible_managed }} - -set -eu - -OPENSEARCH_BIN_PATH=/usr/share/opensearch/bin -OPENSEARCH_SERVICE=opensearch.service -PLUGINS=( - ingest-attachment -) - -ACTION="${1:-help}" - -case "$ACTION" in - purge) - for plugin in "${PLUGINS[@]}"; do - $OPENSEARCH_BIN_PATH/opensearch-plugin remove $plugin --batch - done - systemctl restart $OPENSEARCH_SERVICE - ;; - install) - for plugin in "${PLUGINS[@]}"; do - $OPENSEARCH_BIN_PATH/opensearch-plugin install $plugin --batch - done - systemctl restart $OPENSEARCH_SERVICE - ;; - help) - echo "Syntax: $(basename "$0") { purge | install | help }" - echo - ;; - *) - "$0" help >&2 - exit 1 - ;; -esac