Pour tout problème contactez-nous par mail : support@froggit.fr | La FAQ :grey_question: | Rejoignez-nous sur le Chat :speech_balloon:

Skip to content
Snippets Groups Projects
Commit ac0e9e5f authored by Nicolas's avatar Nicolas
Browse files

feat: add elastic7 playbook

parent e3efb47d
No related branches found
No related tags found
No related merge requests found
- name: "Install Elastic 7"
hosts: es7-1
tasks:
- name: Install components and prerequisites
include_tasks: 01_install-components.yaml
- name: Install Elastic
include_tasks: 02_install-elastic.yaml
- name: Update Elasticsearch configuration file
lineinfile:
path: /etc/elasticsearch/elasticsearch.yml
regexp: "{{ item.regexp }}"
line: "{{ item.line }}"
with_items:
- { regexp: '^cluster.name:', line: 'cluster.name: es7' }
- { regexp: '^node.name:', line: 'node.name: es7-1' }
- { regexp: '^bootstrap.memory_lock:', line: 'bootstrap.memory_lock: true' }
- { regexp: '^network.host:', line: 'network.host: _eth0_' }
- { regexp: '^http.port:', line: 'http.port: 9200' }
- { regexp: '^discovery.seed_hosts:', line: 'discovery.seed_hosts: ["es7-1"]' }
- { regexp: '^cluster.initial_master_nodes:', line: 'cluster.initial_master_nodes: ["es7-1"]' }
- name: Configure Elastic
include_tasks: 03_configure-elastic.yaml
- name: Install JRE
apt:
name: default-jre
state: present
- name: Install JDK
apt:
name: default-jdk
state: present
- name: Install gnupg2
apt:
name: gnupg2
state: present
- name: Add Elasticsearch repository key
apt_key:
url: "https://artifacts.elastic.co/GPG-KEY-elasticsearch"
id: "46095ACC8548582C1A2699A9D27D666CD88E42B4"
state: present
- name: Add elasticsearch repository
apt_repository:
repo: "deb https://artifacts.elastic.co/packages/7.x/apt stable main"
state: present
- name: Update APT
apt:
update_cache: yes
- name: Install Elastic
apt:
name: elasticsearch=7.17.11
- name: Update Security limits
blockinfile:
path: /etc/security/limits.conf
block: |
# Source: https://www.elastic.co/guide/en/elasticsearch/reference/7.17/setup-configuration-memory.html#bootstrap-memory_lock
# allow user 'elasticsearch' mlockall
elasticsearch soft memlock unlimited
elasticsearch hard memlock unlimited
######
# Source : https://www.elastic.co/guide/en/elasticsearch/reference/7.17/setting-system-settings.html#limits.conf
elasticsearch - nofile 65535
- name: Check if JVM options file exists
stat:
path: /etc/elasticsearch/jvm.options.d/jvm.options
register: jvm_options_file
- name: Create JVM options file
file:
path: /etc/elasticsearch/jvm.options.d/jvm.options
state: touch
owner: root
group: root
mode: '0644'
force: yes
when: not jvm_options_file.stat.exists
- name: Update JVM options file
blockinfile:
path: /etc/elasticsearch/jvm.options.d/jvm.options
block: |
# Source: https://www.elastic.co/guide/en/elasticsearch/reference/7.17/advanced-configuration.html#set-jvm-heap-size
-Xms2g
-Xmx2g
- name: Check if Elasticsearch service override folder exists
stat:
path: /etc/systemd/system/elasticsearch.service.d
register: elastic_service_override_folder
- name: Create Elasticsearch service override folder
file:
path: /etc/systemd/system/elasticsearch.service.d
state: directory
when: not elastic_service_override_folder.stat.exists
- name: Check if Elasticsearch service override file exists
stat:
path: /etc/systemd/system/elasticsearch.service.d/override.conf
register: elastic_service_override_file
- name: Create Elasticsearch service override file
file:
path: /etc/systemd/system/elasticsearch.service.d/override.conf
state: touch
owner: root
group: root
mode: '0644'
force: yes
when: not elastic_service_override_file.stat.exists
- name: Update Elasticsearch service override file
blockinfile:
path: /etc/systemd/system/elasticsearch.service.d/override.conf
block: |
# Source: https://www.elastic.co/guide/en/elasticsearch/reference/7.11/setting-system-settings.html#systemd
[Service]
LimitMEMLOCK=infinity
- name: Reload daemon
systemd:
daemon_reload: yes
- name: Enable Elasticsearch service
systemd:
name: elasticsearch
enabled: yes
- name: Start Elasticsearch service
systemd:
name: elasticsearch
state: restarted
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment