Proxmox: node1-3 → 10.0.19.101-103 Talos cp1-3 → 10.0.19.1-3, workers → 10.0.19.4-6 K8s endpoint → VIP https://10.0.19.10:6443 Ansible: prom → 10.0.19.31, db → 10.0.19.30 Talos: added VIP block to controlplane.yaml base config Promtail: Loki URL → 10.0.19.31 Docs: all references updated, talos4 removed
179 lines
5.7 KiB
YAML
179 lines
5.7 KiB
YAML
---
|
|
# Installs OpenSearch from the upstream tarball (bundled JDK) and runs it
|
|
# under systemd in single-node mode for logs.vntx.net.
|
|
|
|
- name: Set vm.max_map_count for OpenSearch
|
|
ansible.posix.sysctl:
|
|
name: vm.max_map_count
|
|
value: "{{ opensearch_vm_max_map_count }}"
|
|
state: present
|
|
reload: true
|
|
|
|
- name: Create opensearch group
|
|
ansible.builtin.group:
|
|
name: "{{ opensearch_group }}"
|
|
system: true
|
|
state: present
|
|
|
|
- name: Create opensearch user
|
|
ansible.builtin.user:
|
|
name: "{{ opensearch_user }}"
|
|
group: "{{ opensearch_group }}"
|
|
system: true
|
|
shell: /usr/sbin/nologin
|
|
home: "{{ opensearch_data_dir }}"
|
|
create_home: false
|
|
state: present
|
|
|
|
- name: Create opensearch directories
|
|
ansible.builtin.file:
|
|
path: "{{ item }}"
|
|
state: directory
|
|
owner: "{{ opensearch_user }}"
|
|
group: "{{ opensearch_group }}"
|
|
mode: "0750"
|
|
loop:
|
|
- "{{ opensearch_install_dir }}"
|
|
- "{{ opensearch_config_dir }}"
|
|
- "{{ opensearch_data_dir }}"
|
|
- "{{ opensearch_log_dir }}"
|
|
|
|
- name: Check installed opensearch version
|
|
ansible.builtin.command: "{{ opensearch_install_dir }}/bin/opensearch --version"
|
|
register: opensearch_installed
|
|
changed_when: false
|
|
failed_when: false
|
|
|
|
- name: Decide whether opensearch needs (re)install
|
|
ansible.builtin.set_fact:
|
|
opensearch_needs_install: >-
|
|
{{
|
|
opensearch_installed.rc != 0
|
|
or opensearch_version not in (opensearch_installed.stdout | default(''))
|
|
and opensearch_version not in (opensearch_installed.stderr | default(''))
|
|
}}
|
|
|
|
- name: Download opensearch tarball
|
|
ansible.builtin.get_url:
|
|
url: "https://artifacts.opensearch.org/releases/bundle/opensearch/{{ opensearch_version }}/opensearch-{{ opensearch_version }}-linux-{{ opensearch_arch }}.tar.gz"
|
|
dest: "/tmp/opensearch-{{ opensearch_version }}-linux-{{ opensearch_arch }}.tar.gz"
|
|
mode: "0644"
|
|
when: opensearch_needs_install
|
|
|
|
- name: Extract opensearch tarball to install dir
|
|
ansible.builtin.unarchive:
|
|
src: "/tmp/opensearch-{{ opensearch_version }}-linux-{{ opensearch_arch }}.tar.gz"
|
|
dest: "{{ opensearch_install_dir }}"
|
|
remote_src: true
|
|
extra_opts:
|
|
- --strip-components=1
|
|
owner: "{{ opensearch_user }}"
|
|
group: "{{ opensearch_group }}"
|
|
when: opensearch_needs_install
|
|
notify: Restart opensearch
|
|
|
|
- name: Render opensearch.yml
|
|
ansible.builtin.template:
|
|
src: opensearch.yml.j2
|
|
dest: "{{ opensearch_config_dir }}/opensearch.yml"
|
|
owner: "{{ opensearch_user }}"
|
|
group: "{{ opensearch_group }}"
|
|
mode: "0640"
|
|
notify: Restart opensearch
|
|
|
|
- name: Render jvm.options
|
|
ansible.builtin.template:
|
|
src: jvm.options.j2
|
|
dest: "{{ opensearch_config_dir }}/jvm.options"
|
|
owner: "{{ opensearch_user }}"
|
|
group: "{{ opensearch_group }}"
|
|
mode: "0640"
|
|
notify: Restart opensearch
|
|
|
|
- name: Install opensearch systemd unit
|
|
ansible.builtin.template:
|
|
src: opensearch.service.j2
|
|
dest: /etc/systemd/system/opensearch.service
|
|
owner: root
|
|
group: root
|
|
mode: "0644"
|
|
notify: Restart opensearch
|
|
|
|
- name: Enable and start opensearch
|
|
ansible.builtin.systemd:
|
|
name: opensearch
|
|
enabled: true
|
|
state: started
|
|
daemon_reload: true
|
|
|
|
# --- OpenSearch Dashboards ---
|
|
|
|
- name: Create opensearch-dashboards directories
|
|
ansible.builtin.file:
|
|
path: "{{ item }}"
|
|
state: directory
|
|
owner: "{{ opensearch_user }}"
|
|
group: "{{ opensearch_group }}"
|
|
mode: "0750"
|
|
loop:
|
|
- "{{ opensearch_dashboards_install_dir }}"
|
|
- "{{ opensearch_dashboards_config_dir }}"
|
|
|
|
- name: Check installed opensearch-dashboards version
|
|
ansible.builtin.command: "{{ opensearch_dashboards_install_dir }}/bin/opensearch-dashboards --version"
|
|
register: dashboards_installed
|
|
changed_when: false
|
|
failed_when: false
|
|
|
|
- name: Decide whether dashboards needs (re)install
|
|
ansible.builtin.set_fact:
|
|
dashboards_needs_install: >-
|
|
{{
|
|
dashboards_installed.rc != 0
|
|
or opensearch_dashboards_version not in (dashboards_installed.stdout | default(''))
|
|
and opensearch_dashboards_version not in (dashboards_installed.stderr | default(''))
|
|
}}
|
|
|
|
- name: Download opensearch-dashboards tarball
|
|
ansible.builtin.get_url:
|
|
url: "https://artifacts.opensearch.org/releases/bundle/opensearch-dashboards/{{ opensearch_dashboards_version }}/opensearch-dashboards-{{ opensearch_dashboards_version }}-linux-{{ opensearch_arch }}.tar.gz"
|
|
dest: "/tmp/opensearch-dashboards-{{ opensearch_dashboards_version }}-linux-{{ opensearch_arch }}.tar.gz"
|
|
mode: "0644"
|
|
when: dashboards_needs_install
|
|
|
|
- name: Extract opensearch-dashboards tarball to install dir
|
|
ansible.builtin.unarchive:
|
|
src: "/tmp/opensearch-dashboards-{{ opensearch_dashboards_version }}-linux-{{ opensearch_arch }}.tar.gz"
|
|
dest: "{{ opensearch_dashboards_install_dir }}"
|
|
remote_src: true
|
|
extra_opts:
|
|
- --strip-components=1
|
|
owner: "{{ opensearch_user }}"
|
|
group: "{{ opensearch_group }}"
|
|
when: dashboards_needs_install
|
|
notify: Restart opensearch-dashboards
|
|
|
|
- name: Render opensearch-dashboards.yml
|
|
ansible.builtin.template:
|
|
src: opensearch-dashboards.yml.j2
|
|
dest: "{{ opensearch_dashboards_config_dir }}/opensearch_dashboards.yml"
|
|
owner: "{{ opensearch_user }}"
|
|
group: "{{ opensearch_group }}"
|
|
mode: "0640"
|
|
notify: Restart opensearch-dashboards
|
|
|
|
- name: Install opensearch-dashboards systemd unit
|
|
ansible.builtin.template:
|
|
src: opensearch-dashboards.service.j2
|
|
dest: /etc/systemd/system/opensearch-dashboards.service
|
|
owner: root
|
|
group: root
|
|
mode: "0644"
|
|
notify: Restart opensearch-dashboards
|
|
|
|
- name: Enable and start opensearch-dashboards
|
|
ansible.builtin.systemd:
|
|
name: opensearch-dashboards
|
|
enabled: true
|
|
state: started
|
|
daemon_reload: true
|