---
- name: Ensure the key is present
  apt_key:
    url: http://packages.elasticsearch.org/GPG-KEY-elasticsearch
- name: Add repository
  apt_repository:
    repo: 'deb http://packages.elasticsearch.org/logstash/1.4/debian stable main'
    state: present
  notify:
  - Update apt
- name: Ensure logstash is installed
  apt:
    pkg: logstash
    state: latest
- name: Ensure the logstash config is ok
  copy:
    src: logstash.conf
    dest: /etc/logstash/conf.d/logstash.conf
- name: Ensure the host is correctly written in the conf
  lineinfile:
    dest: /etc/logstash/conf.d/logstash.conf
    insertafter: "    # host here"
    line: "    host => '{{ monitoring_server }}'"
- name: Modify logstash to run as adm group to read logs
  lineinfile:
    dest: /etc/default/logstash
    insertafter: "#LS_USER"
    line: "LS_GROUP=adm"
- name: Ensure logstash is running
  service: 
    name: logstash
    state: restarted
    enabled: yes
---
- name: Ensure the key is present
  apt_key:
    url: http://packages.elasticsearch.org/GPG-KEY-elasticsearch
- name: Add repository
  apt_repository:
    repo: 'deb http://packages.elasticsearch.org/logstash/1.4/debian stable main'
    state: present
  notify:
  - Update apt
- name: Ensure logstash is installed
  apt:
    pkg: logstash
    state: latest
- name: Ensure the logstash config is ok
  copy:
    src: logstash.conf
    dest: /etc/logstash/conf.d/logstash.conf
- name: Ensure the host is correctly written in the conf
  lineinfile:
    dest: /etc/logstash/conf.d/logstash.conf
    insertafter: "    # host here"
    line: |
              host => '{{ monitoring_server }}'
              port => 8080
              user => {{ user }}
              password => "{{ lookup('file', '/tmp/ansible.password.elasticsearch_proxy') }}"
- name: Modify logstash to run as adm group to read logs
  lineinfile:
    dest: /etc/default/logstash
    insertafter: "#LS_USER"
    line: "LS_GROUP=adm"
- name: Ensure logstash is running
  service: 
    name: logstash
    state: restarted
    enabled: yes
Add the correct elastic search info for logstash
Add the correct elastic search info for logstash
