---
# file: roles/netdata/tasks/prepare.yml

- name: Install required packages
  apt:
    pkg: '{{ packages }}'
    state: present
    update_cache: yes
  vars:
    packages:
      - zlib1g-dev
      - gcc
      - make
      - git
      - autoconf
      - autogen
      - automake
      - pkg-config
      - uuid-dev
      - python-dev
      - python-yaml
      - python3-dev
      - librsync-dev
      - libuv1-dev

- name: Remove existing components
  file:
    path: '{{ item }}'
    state: absent
  with_items:
    - /opt/{{ netdata_local_archive|default("netdata") }}
    - /etc/netdata
    - /etc/init.d/netdata
    - /etc/logrotate.d/netdata
  when: netdata_force_reset

- name: Ensure Directory
  file:
    path: /etc/netdata/python.d
    state: directory
