mirror of
https://git.lapiole.org/dani/ansible-roles.git
synced 2025-08-07 17:16:55 +02:00
Update to 2022-01-25 15:00
This commit is contained in:
@@ -1,10 +1,64 @@
|
||||
---
|
||||
|
||||
- name: Install needed packages
|
||||
yum:
|
||||
name:
|
||||
- elasticsearch-oss
|
||||
- java-1.8.0-openjdk-headless
|
||||
- name: Stop the service during upgrades
|
||||
service: name=elasticsearch state=stopped
|
||||
when: es_install_mode == 'upgrade'
|
||||
tags: es
|
||||
|
||||
- name: Stop seafile to free elasticsearch port
|
||||
service: name=seafile state=stopped
|
||||
when: es_seafile_bundled_es.stat.exists and es_seafile_service.stat.exists
|
||||
tags: es
|
||||
|
||||
- when: es_install_mode != 'none'
|
||||
block:
|
||||
- name: Download Elasticsearch {{ es_version }}
|
||||
get_url:
|
||||
url: "{{ es_archive_url }}"
|
||||
dest: "{{ es_root_dir }}/tmp"
|
||||
checksum: sha512:{{ es_archive_sha512 }}
|
||||
|
||||
- name: Extract the archive
|
||||
unarchive:
|
||||
src: "{{ es_root_dir }}/tmp/elasticsearch-{{ es_version }}-linux-x86_64.tar.gz"
|
||||
dest: "{{ es_root_dir }}/tmp"
|
||||
remote_src: True
|
||||
|
||||
- name: Move Elasticsearch to its final dir
|
||||
synchronize:
|
||||
src: "{{ es_root_dir }}/tmp/elasticsearch-{{ es_version }}/"
|
||||
dest: "{{ es_root_dir }}/app/"
|
||||
delete: True
|
||||
compress: False
|
||||
delegate_to: "{{ inventory_hostname }}"
|
||||
|
||||
- name: Populate config dir
|
||||
synchronize:
|
||||
src: "{{ es_root_dir }}/tmp/elasticsearch-{{ es_version }}/config/"
|
||||
dest: "{{ es_root_dir }}/etc/"
|
||||
delete: True
|
||||
compress: False
|
||||
delegate_to: "{{ inventory_hostname }}"
|
||||
|
||||
- name: Set permissions
|
||||
shell: |
|
||||
{% if ansible_selinux.status == 'enabled' %}
|
||||
restorecon -R {{ es_root_dir }}
|
||||
{% endif %}
|
||||
chown -R root:root {{ es_root_dir }}/app
|
||||
chown -R :{{ es_user }} {{ es_root_dir }}/etc
|
||||
chown -R {{ es_user }}:{{ es_user }} {{ es_root_dir }}/data/*
|
||||
find {{ es_root_dir }}/etc -type d -exec chmod 770 "{}" \;
|
||||
find {{ es_root_dir }}/etc -type f -exec chmod 660 "{}" \;
|
||||
find {{ es_root_dir }}/app -type d -exec chmod 755 "{}" \;
|
||||
find {{ es_root_dir }}/app -type f -exec chmod 644 "{}" \;
|
||||
find {{ es_root_dir }}/app/jdk/bin -type f -exec chmod 755 "{}" \;
|
||||
chmod 755 {{ es_root_dir }}/app/jdk/lib/jspawnhelper
|
||||
find {{ es_root_dir }}/app/bin -type f -exec chmod 755 "{}" \;
|
||||
find {{ es_root_dir }}/app/modules/x-pack-ml/platform/linux-x86_64/bin/ -type f -exec chmod 755 "{}" \;
|
||||
args:
|
||||
warn: False
|
||||
|
||||
tags: es
|
||||
|
||||
- name: Deploy pre and post backup script
|
||||
@@ -14,29 +68,30 @@
|
||||
- post
|
||||
tags: es
|
||||
|
||||
- name: Create systemd unit snippet dir
|
||||
file: path=/etc/systemd/system/elasticsearch.service.d state=directory
|
||||
- name: Deploy tmpfile fragment
|
||||
template: src=tmpfiles.conf.j2 dest=/etc/tmpfiles.d/elasticsearch.conf
|
||||
register: es_tmpfiles
|
||||
tags: es
|
||||
|
||||
- name: Customize systemd unit
|
||||
copy:
|
||||
content: |
|
||||
[Service]
|
||||
ProtectSystem=full
|
||||
PrivateDevices=yes
|
||||
ProtectHome=yes
|
||||
NoNewPrivileges=yes
|
||||
SyslogIdentifier=elasticsearch
|
||||
Restart=on-failure
|
||||
ExecStart=
|
||||
ExecStart=/usr/share/elasticsearch/bin/elasticsearch -p ${PID_DIR}/elasticsearch.pid
|
||||
dest: /etc/systemd/system/elasticsearch.service.d/ansible.conf
|
||||
- name: Create tmpfiles
|
||||
command: systemd-tmpfiles --create
|
||||
when: es_tmpfiles.changed
|
||||
tags: es
|
||||
|
||||
- name: Deploy systemd unit
|
||||
template: src=elasticsearch.service.j2 dest=/etc/systemd/system/elasticsearch.service
|
||||
register: es_unit
|
||||
notify: restart elasticsearch
|
||||
tags: es
|
||||
|
||||
- name: Remove previous systemd unit snippet
|
||||
file: path=/etc/systemd/system/elasticsearch.service.d/ansible.conf state=absent
|
||||
register: es_unit_snip
|
||||
notify: restart elasticsearch
|
||||
tags: es
|
||||
|
||||
- name: Reload systemd
|
||||
systemd: daemon_reload=True
|
||||
when: es_unit.changed
|
||||
when: es_unit.changed or es_unit_snip.changed
|
||||
tags: es
|
||||
|
||||
|
Reference in New Issue
Block a user