69 lines
2 KiB
YAML
69 lines
2 KiB
YAML
---
|
|
- name: "Opensearch | Add repository key"
|
|
ansible.builtin.get_url:
|
|
url: "{{ opensearch_apt_key_url }}"
|
|
dest: /etc/apt/trusted.gpg.d/opensearch.asc
|
|
mode: "0644"
|
|
|
|
- name: "Opensearch | Add repository"
|
|
ansible.builtin.apt_repository:
|
|
repo: "deb {{ opensearch_apt_repo }}"
|
|
update_cache: true
|
|
|
|
- name: "Opensearch | Install opensearch"
|
|
ansible.builtin.apt:
|
|
name: opensearch
|
|
allow_change_held_packages: true
|
|
|
|
- name: Opensearch | Hold package
|
|
ansible.builtin.dpkg_selections:
|
|
name: opensearch
|
|
selection: hold
|
|
when: opensearch_plugins is defined
|
|
|
|
- name: "Opensearch | Install plugins"
|
|
ansible.builtin.command:
|
|
cmd: "./opensearch-plugin install {{ item }} --batch"
|
|
chdir: /usr/share/opensearch/bin/
|
|
creates: "/usr/share/opensearch/plugins/{{ item }}"
|
|
become: true
|
|
become_user: opensearch
|
|
loop: "{{ opensearch_plugins }}"
|
|
|
|
- name: "Opensearch | Copy opensearch configuration"
|
|
ansible.builtin.template:
|
|
src: opensearch.yml.j2
|
|
dest: /etc/opensearch/opensearch.yml
|
|
mode: "0644"
|
|
|
|
- name: "Opensearch | Add recommendations for JVM options"
|
|
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: Copy systemd override
|
|
ansible.builtin.copy:
|
|
src: systemd/override.conf
|
|
dest: /etc/systemd/system/opensearch.service.d/
|
|
mode: "0644"
|
|
notify: restart opensearch
|
|
|
|
- name: "Opensearch | Start opensearch"
|
|
ansible.builtin.systemd:
|
|
name: opensearch
|
|
enabled: true
|
|
state: started
|
|
daemon_reload: true
|
|
|
|
- name: "Opensearch | Copy update script"
|
|
ansible.builtin.template:
|
|
src: update-opensearch-plugins.j2
|
|
dest: "/usr/local/bin/{{ opensearch_plugin_update_script }}"
|
|
mode: "0755"
|