--- # Configure Elasticsearch Node #Use systemd for the following distributions: # #Ubuntu 15 and up #Debian 8 and up #Centos 7 and up #Relies on elasticsearch distribution installing a serviced script to determine whether one should be copied. - set_fact: use_system_d={{(ansible_distribution == 'Debian' and ansible_distribution_version | version_compare('8', '>=')) or (ansible_distribution == 'CentOS' and ansible_distribution_version | version_compare('7', '>=')) or (ansible_distribution == 'Ubuntu' and ansible_distribution_version | version_compare('15', '>=')) }} - set_fact: instance_sysd_script={{sysd_script | dirname }}/{{es_instance_name}}_{{sysd_script | basename}} when: use_system_d #For directories we also use the {{inventory_hostname}}-{{ es_instance_name }} - this helps if we have a shared SAN. - set_fact: pid_dir={{ es_pid_dir }}/{{inventory_hostname}}-{{ es_instance_name }} - set_fact: data_dir={{ es_data_dir }}/{{inventory_hostname}}-{{ es_instance_name }} - set_fact: log_dir={{ es_log_dir }}/{{inventory_hostname}}-{{ es_instance_name }} - set_fact: work_dir={{ es_work_dir }}/{{inventory_hostname}}-{{ es_instance_name }} #Create required directories - name: Create PID Directory file: path={{ pid_dir }} state=directory owner={{ es_user }} group={{ es_group }} - name: Create data dir file: state=directory path={{ data_dir }} owner={{ es_user }} group={{ es_group }} - name: Create work dir file: state=directory path={{ work_dir }} owner={{ es_user }} group={{ es_group }} - name: Create log dir file: state=directory path={{ log_dir }} owner={{ es_user }} group={{ es_group }} - name: Create Config Directory file: path={{ conf_dir }} state=directory owner={{ es_user }} group={{ es_group }} - name: Create Plugin Directory file: state=directory path={{ plugin_dir }} owner={{ es_user }} group={{ es_group }} #Copy the config template - name: Copy Configuration File template: src=elasticsearch.yml.j2 dest={{conf_dir}}/elasticsearch.yml owner={{ es_user }} group={{ es_group }} mode=0644 force=yes notify: restart elasticsearch #Copy the instance specific default file - name: Copy Default File for Instance template: src=elasticsearch.j2 dest={{instance_default_file}} mode=0644 force=yes notify: restart elasticsearch #Copy the instance specific init file - name: Copy Debian Init File for Instance template: src=init/debian/elasticsearch.j2 dest={{instance_init_script}} mode=0755 force=yes when: ansible_os_family == 'Debian' notify: restart elasticsearch #Copy the instance specific init file - name: Copy Redhat Init File for Instance template: src=init/redhat/elasticsearch.j2 dest={{instance_init_script}} mode=0755 force=yes when: ansible_os_family == 'RedHat' notify: restart elasticsearch #Copy the systemd specific file if systemd is installed - name: Copy Systemd File for Instance template: src=systemd/elasticsearch.j2 dest={{instance_sysd_script}} mode=0644 force=yes when: use_system_d notify: restart elasticsearch #Copy the logging.yml - name: Copy Logging.yml File for Instance template: src=logging.yml.j2 dest={{conf_dir}}/logging.yml owner={{ es_user }} group={{ es_group }} mode=0644 force=yes notify: restart elasticsearch #Clean up un-wanted package scripts to avoid confusion - name: Delete Default Init file: dest=/etc/init.d/elasticsearch state=absent - name: Delete Default Environment File file: dest=/etc/default/elasticsearch state=absent when: ansible_os_family == 'Debian' - name: Delete Default Environment File file: dest=/etc/sysconfig/elasticsearch state=absent when: ansible_os_family == 'RedHat' - name: Delete Default Sysconfig File file: dest=/usr/lib/systemd/system/elasticsearch.service state=absent