2023-05-13 08:30:14 +02:00
|
|
|
---
|
2023-07-04 22:11:22 +02:00
|
|
|
- name: "Opensearch | Add repository key"
|
2024-01-21 10:14:34 +01:00
|
|
|
ansible.builtin.get_url:
|
2023-05-13 08:30:14 +02:00
|
|
|
url: "{{ opensearch_apt_key_url }}"
|
2024-01-21 10:14:34 +01:00
|
|
|
dest: /etc/apt/trusted.gpg.d/opensearch.asc
|
|
|
|
mode: "0644"
|
2023-05-13 08:30:14 +02:00
|
|
|
|
2023-07-04 22:11:22 +02:00
|
|
|
- name: "Opensearch | Add repository"
|
2023-05-13 08:30:14 +02:00
|
|
|
ansible.builtin.apt_repository:
|
|
|
|
repo: "deb {{ opensearch_apt_repo }}"
|
|
|
|
update_cache: true
|
|
|
|
|
2023-07-04 22:11:22 +02:00
|
|
|
- name: "Opensearch | Install opensearch"
|
2023-05-13 08:30:14 +02:00
|
|
|
ansible.builtin.apt:
|
|
|
|
name: opensearch
|
2024-01-21 12:16:59 +01:00
|
|
|
allow_change_held_packages: true
|
|
|
|
|
|
|
|
- name: Opensearch | Hold package
|
|
|
|
ansible.builtin.dpkg_selections:
|
|
|
|
name: opensearch
|
|
|
|
selection: hold
|
|
|
|
when: opensearch_plugins is defined
|
2023-05-13 08:30:14 +02:00
|
|
|
|
2023-07-04 22:11:22 +02:00
|
|
|
- name: "Opensearch | Install plugins"
|
2023-05-13 08:30:14 +02:00
|
|
|
ansible.builtin.command:
|
2023-07-04 22:20:14 +02:00
|
|
|
cmd: "./opensearch-plugin install {{ item }} --batch"
|
2023-05-13 08:30:14 +02:00
|
|
|
chdir: /usr/share/opensearch/bin/
|
2023-07-04 22:20:14 +02:00
|
|
|
creates: "/usr/share/opensearch/plugins/{{ item }}"
|
2023-05-13 08:30:14 +02:00
|
|
|
become: true
|
|
|
|
become_user: opensearch
|
2023-07-04 22:20:14 +02:00
|
|
|
loop: "{{ opensearch_plugins }}"
|
2023-05-13 08:30:14 +02:00
|
|
|
|
2023-07-04 22:11:22 +02:00
|
|
|
- name: "Opensearch | Copy opensearch configuration"
|
2023-05-13 08:30:14 +02:00
|
|
|
ansible.builtin.template:
|
|
|
|
src: opensearch.yml.j2
|
|
|
|
dest: /etc/opensearch/opensearch.yml
|
|
|
|
mode: "0644"
|
|
|
|
|
2023-07-04 22:11:22 +02:00
|
|
|
- name: "Opensearch | Add recommendations for JVM options"
|
2023-05-13 08:30:14 +02:00
|
|
|
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
|
|
|
|
|
2023-12-06 10:46:59 +01:00
|
|
|
- name: Copy systemd override
|
|
|
|
ansible.builtin.copy:
|
|
|
|
src: systemd/override.conf
|
|
|
|
dest: /etc/systemd/system/opensearch.service.d/
|
|
|
|
mode: "0644"
|
|
|
|
notify: restart opensearch
|
|
|
|
|
2023-07-04 22:11:22 +02:00
|
|
|
- name: "Opensearch | Start opensearch"
|
2023-05-13 08:30:14 +02:00
|
|
|
ansible.builtin.systemd:
|
|
|
|
name: opensearch
|
|
|
|
enabled: true
|
|
|
|
state: started
|
|
|
|
daemon_reload: true
|
|
|
|
|
2023-07-04 22:11:22 +02:00
|
|
|
- name: "Opensearch | Copy update script"
|
2023-05-13 08:30:14 +02:00
|
|
|
ansible.builtin.template:
|
|
|
|
src: update-opensearch-plugins.j2
|
|
|
|
dest: "/usr/local/bin/{{ opensearch_plugin_update_script }}"
|
|
|
|
mode: "0755"
|