---
# file: roles/elastalert/tasks/install.yml

- name: Ensure ElastAlert Directories
  file:
    dest: /opt/elastalert/{{ item }}
    state: directory
  with_items:
    - config
    - rules

- name: Copy config files
  template:
    src: '{{ item }}'
    dest: /opt/elastalert/config/{{ item }}
    owner: root
    group: root
    mode: 0644
  with_items:
    - config.json
    - elastalert.yaml
    - elastalert-test.yaml
  tags:
    - Config
  notify:
    - Re-create the elastalert container

- name: Pull docker image
  docker_image:
    name: bitsensor/elastalert:{{ elastalert_version }}
    source: pull
    force_source: yes
  notify:
    - Re-create the elastalert container
