ansible-role-zammad/tasks/opensearch.yml

98 lines
3.1 KiB
YAML

---
- 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 }}')"
chdir: "{{ zammad_home }}"
environment:
RAILS_ENV: production
become: true
become_user: "{{ zammad_user }}"
- name: "Opensearch | Konfiguriere Index-Namespacing"
ansible.builtin.shell:
cmd: rbenv exec bundle exec rails r "Setting.set('es_index', Socket.gethostname.downcase + '_zammad')"
chdir: "{{ zammad_home }}"
environment:
RAILS_ENV: production
become: true
become_user: "{{ zammad_user }}"
- name: "Opensearch | Erstelle Such-Index"
ansible.builtin.shell:
cmd: rbenv exec bundle exec rake zammad:searchindex:rebuild
chdir: "{{ zammad_home }}"
environment:
RAILS_ENV: production
become: true
become_user: "{{ zammad_user }}"
- name: "Opensearch | Konfiguriere Datei-Erweiterungen"
ansible.builtin.shell:
cmd: rbenv exec bundle exec rails r "Setting.set('es_attachment_ignore', [ '.png', '.jpg', '.jpeg', '.mpeg', '.mpg', '.mov', '.bin', '.exe', '.box', '.mbox' ] )"
chdir: "{{ zammad_home }}"
environment:
RAILS_ENV: production
become: true
become_user: "{{ zammad_user }}"
- 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 }})"
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
dest: /etc/monit/conf-enabled/opensearch
mode: 0644
notify: reload monit