Skip to content
Snippets Groups Projects
configure.yml 2.09 KiB
---
# file: roles/netdata/tasks/configure.yml

- name: Add User to Admins
  user:
    name: netdata
    groups: adm
    append: yes

- name: Configure Registry
  ini_file:
    dest: /etc/netdata/netdata.conf
    create: yes
    section: registry
    option: '{{ item.option }}'
    value: '{{ item.value }}'
  with_items:
    - option: enabled
      value: '{{ (netdata_registry|default("pmon1") == inventory_hostname)|ternary("yes", "no") }}'
    - option: registry to announce
      value: 'http://{{ netdata_registry|default("pmon1") }}:19999'
  notify:
    - Restart NetData

- name: Configure NetData
  template:
    src: '{{ item }}'
    dest: /etc/netdata/{{ item }}
    owner: netdata
    group: netdata
    mode: 0644
    backup: yes
  with_items:
    - health_alarm_notify.conf
    - python.d.conf
    - go.d.conf
  notify:
    - Restart NetData

- name: Configure Python Plugins
  template:
    src: '{{ item }}'
    dest: /etc/netdata/python.d/{{ item }}
    owner: netdata
    group: netdata
    mode: 0644
    backup: yes
  with_items:
    - httpcheck.conf
  notify:
    - Restart NetData

- name: Get a list of all health config files
  shell: ls /usr/lib/netdata/conf.d/health.d/*.conf -1
  register: health_list

- name: Remove all options that prevent clear notifications
  lineinfile:
    path: '{{ item }}'
    state: absent
    regexp: no-clear-notification
  with_items: '{{ health_list.stdout_lines }}'
  notify:
    - Restart NetData

- name: Patch Startup Script
  lineinfile:
    dest: /etc/init.d/netdata
    regexp: 'killproc -p \$\{PIDFILE\} \$DAEMON_PATH/\$DAEMON'
    line: '        killproc -p ${PIDFILE} $DAEMON_PATH/$DAEMON && sleep 3'