146 lines
4.0 KiB
YAML
146 lines
4.0 KiB
YAML
---
|
|
- name: Opensearch installation
|
|
block:
|
|
- name: Create the opensearch user, {{ opensearch_user }}
|
|
user:
|
|
name: '{{ opensearch_user }}'
|
|
home: '{{ opensearch_base_install_dir }}'
|
|
createhome: false
|
|
shell: /sbin/nologin
|
|
system: true
|
|
|
|
- name: Create the opensearch data directories
|
|
file:
|
|
dest: '{{ item }}'
|
|
state: directory
|
|
owner: '{{ opensearch_user }}'
|
|
group: '{{ opensearch_user }}'
|
|
mode: 0750
|
|
loop: '{{ opensearch_data_dirs }}'
|
|
|
|
- name: Create the opensearch log directory {{ opensearch_log_dir }}
|
|
file:
|
|
dest: '{{ opensearch_log_dir }}'
|
|
state: directory
|
|
owner: '{{ opensearch_user }}'
|
|
group: '{{ opensearch_user }}'
|
|
recurse: true
|
|
mode: 0750
|
|
|
|
- name: Get the opensearch distribution
|
|
get_url:
|
|
url: '{{ opensearch_download_url }}'
|
|
dest: /srv
|
|
register: opensearch_download
|
|
|
|
- name: Get the opensearch cli tools
|
|
get_url:
|
|
url: '{{ opensearch_cli_tools_url }}'
|
|
dest: /srv
|
|
|
|
- name: Unpack the opensearch distribution
|
|
unarchive:
|
|
src: '/srv/{{ opensearch_filename }}'
|
|
remote_src: true
|
|
dest: /opt
|
|
owner: root
|
|
group: root
|
|
mode: 'u+rX,g+rX,o+rX'
|
|
when: opensearch_download is changed
|
|
|
|
- name: Create a link to the correct place
|
|
file:
|
|
src: '/opt/{{ opensearch_versioned }}'
|
|
dest: '{{ opensearch_base_install_dir }}'
|
|
state: link
|
|
|
|
- name: Opensearch want to write inside the config directory
|
|
file:
|
|
dest: '{{ opensearch_config_dir }}'
|
|
state: directory
|
|
owner: '{{ opensearch_user }}'
|
|
group: '{{ opensearch_user }}'
|
|
mode: 0755
|
|
|
|
|
|
tags: ['opensearch']
|
|
|
|
- name: Opensearch plugins
|
|
block:
|
|
- name: Create the opensearch 'disabled_plugins' directory
|
|
file:
|
|
dest: '{{ opensearch_disabled_plugins_dir }}'
|
|
state: directory
|
|
owner: root
|
|
group: root
|
|
mode: 0755
|
|
|
|
- name: Manage the security plugin
|
|
command: mv {{ opensearch_plugins_dir }}/opensearch-security {{ opensearch_disabled_plugins_dir }}/opensearch-security
|
|
args:
|
|
creates: '{{ opensearch_disabled_plugins_dir }}/opensearch-security'
|
|
when: not opensearch_security_enabled
|
|
|
|
- name: Manage the security plugin
|
|
command: mv {{ opensearch_disabled_plugins_dir }}/opensearch-security {{ opensearch_plugins_dir }}/opensearch-security
|
|
args:
|
|
creates: '{{ opensearch_plugins_dir }}/opensearch-security'
|
|
when: opensearch_security_enabled
|
|
|
|
tags: ['opensearch', 'opensearch_plugins']
|
|
|
|
- name: Opensearch configuration
|
|
block:
|
|
- name: Install the opensearch JVM options
|
|
template:
|
|
src: jvm.options.j2
|
|
dest: '{{ opensearch_config_dir }}/jvm.options'
|
|
owner: root
|
|
group: '{{ opensearch_user }}'
|
|
mode: 0640
|
|
notify: Restart opensearch
|
|
|
|
- name: Install the opensearch configuration
|
|
template:
|
|
src: opensearch.yml.j2
|
|
dest: '{{ opensearch_config_dir }}/opensearch.yml'
|
|
owner: root
|
|
group: '{{ opensearch_user }}'
|
|
mode: 0640
|
|
notify: Restart opensearch
|
|
|
|
tags: ['opensearch', 'opensearch_conf']
|
|
|
|
- name: Opensearch service status
|
|
block:
|
|
- name: Install the opensearch systemd unit
|
|
template:
|
|
src: opensearch.service.j2
|
|
dest: /etc/systemd/system/opensearch.service
|
|
owner: root
|
|
group: root
|
|
mode: 0644
|
|
register: opensearch_unit_update
|
|
notify: Restart opensearch
|
|
|
|
- name: Reload systemd
|
|
systemd:
|
|
daemon_reload: true
|
|
when: opensearch_unit_update is changed
|
|
|
|
- name: Ensure that opensearch is running and enabled
|
|
service:
|
|
name: opensearch
|
|
state: started
|
|
enabled: true
|
|
when: opensearch_enabled
|
|
|
|
- name: Ensure that opensearch is stopped and disabled
|
|
service:
|
|
name: opensearch
|
|
state: stopped
|
|
enabled: false
|
|
when: not opensearch_enabled
|
|
|
|
tags: ['opensearch', 'opensearch_service']
|