---

- name: add logstash repo
  apt_repository:
    repo: "deb http://packages.elastic.co/logstash/2.2/debian stable main"
  become: yes

- name: install logstash
  apt:
    name: logstash
    update_cache: yes
  become: yes

- name: copy logstash config
  template:
    src: logstash.conf
    dest: /etc/logstash/conf.d/logstash.conf
    owner: root
    group: root
    mode: "u=rw,g=rw,o=r"
  become: yes
  register: config

- name: bounce logstash
  service:
    name: logstash
    state: restarted
  become: yes
  when: config.changed

- name: start logstash
  service:
    name: logstash
    state: started
  become: yes
