---
# tasks file for kibana
# include the distro-specific stuff
- include: debian.yml
  when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'

- include: rhel.yml
  when: ansible_distribution == 'CentOS' or ansible_distribution == 'Red Hat Enterprise Linux'


- name: Copy the Kibana config
  template:
      src: kibana.yml
      dest: /etc/kibana/kibana.yml
      owner: root
      group: root
      mode: 0644
  notify: restart kibana

- name: Register the consul service
  consul:
      service_name: kibana
      service_port: 5601
  when: consul_enabled == True

- name: Install and enable the kibana plugins
  command: "./bin/kibana-plugin install {{ item }}"
  args:
    chdir: /usr/share/kibana
  ignore_errors: true
  with_items:
    - xpack
  notify: restart kibana

- name: Destroy and rebuild the caches
  file:
    name: "/usr/share/kibana/optimize/{{ item }}"
    state: absent
  with_items:
    - bundles
    - .babelcache.json
  notify: restart kibana

- name: Open the firewall for Kibana
  firewalld:
    port: 5601/tcp
    immediate: true
    permanent: true
    state: enabled

- name: Start the kibana service
  service: name=kibana state=started


---
# tasks file for kibana
# include the distro-specific stuff
- include: debian.yml
  when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'

- include: rhel.yml
  when: ansible_distribution == 'CentOS' or ansible_distribution == 'Red Hat Enterprise Linux'


- name: Copy the Kibana config
  template:
      src: kibana.yml
      dest: /etc/kibana/kibana.yml
      owner: root
      group: root
      mode: 0644
  notify: restart kibana

- name: Register the consul service
  consul:
      service_name: kibana
      service_port: 5601
  when: consul_enabled == True

- name: Install and enable the kibana plugins
  become: true
  become_user: kibana
  command: "./bin/kibana-plugin install {{ item }}"
  args:
    chdir: /usr/share/kibana
  ignore_errors: true
  with_items:
    - xpack
  notify: restart kibana

- name: Destroy and rebuild the caches
  file:
    name: "/usr/share/kibana/optimize/{{ item }}"
    state: absent
  with_items:
    - bundles
    - .babelcache.json
  notify: restart kibana

- name: Open the firewall for Kibana
  firewalld:
    port: 5601/tcp
    immediate: true
    permanent: true
    state: enabled

- name: Start the kibana service
  service: name=kibana state=started


Install x-pack as the kibana user
Install x-pack as the kibana user
