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
03_configure-elastic.yaml 2.43 KiB
Newer Older
  • Learn to ignore specific revisions
  • Nicolas's avatar
    Nicolas committed
    - 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