- name: Install elasticsearch
  yum: 
    name: elasticsearch 
    state: present

- name: Create datadirectory
  file: 
    path: /data/elasticsearch 
    state: directory 
    owner: elasticsearch 
    mode: 770

- name: Make sure java 8 is used
  lineinfile: 
    dest: /etc/sysconfig/elasticsearch 
    line: 'JAVA_HOME=/usr/lib/jvm/java-1.8.0' 
    state: present

- name: Install elasticsearch configuration file
  template: 
    src: "{{ item }}.j2" 
    dest: "/etc/elasticsearch/{{ item }}"
  with_items:
    - elasticsearch.yml
  notify: restart elasticsearch

- name: Enable and start elasticsearch service
  service: 
    name: elasticsearch 
    state: started 
    enabled: yes


- name: Install elasticsearch
  yum: 
    name: elasticsearch 
    state: present

- name: Create datadirectory
  file: 
    path: /data/elasticsearch 
    state: directory 
    owner: elasticsearch 
    mode: 770

- name: Make sure java 8 is used
  lineinfile: 
    dest: /etc/sysconfig/elasticsearch 
    line: 'JAVA_HOME=/usr/lib/jvm/jre-1.8.0/'
    state: present

- name: Install elasticsearch configuration file
  template: 
    src: "{{ item }}.j2" 
    dest: "/etc/elasticsearch/{{ item }}"
  with_items:
    - elasticsearch.yml
  notify: restart elasticsearch

- name: Enable and start elasticsearch service
  service: 
    name: elasticsearch 
    state: started 
    enabled: yes


Add correct path to Java for Elasticsearch
ELK: Add correct path to Java for Elasticsearch
