From 08e40e4a45d715a367dbd60e3fe89553ce479d2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Duchaussois?= Date: Mon, 1 Mar 2021 18:18:24 +0100 Subject: initial import from private repo --- tasks/main.yml | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++ tasks/uninstall.yml | 13 +++++++++++ 2 files changed, 80 insertions(+) create mode 100644 tasks/main.yml create mode 100644 tasks/uninstall.yml (limited to 'tasks') diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..ca849a3 --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,67 @@ +--- +- name: Install requirements (Debian family) + apt: + name: curl + state: present + when: ansible_os_family == 'Debian' + +- name: Install requirements (Redhat family) + yum: + name: curl + state: present + when: ansible_os_family == 'RedHat' + +- name: Check if netdata is installed + command: "{{ prefix }}netdata -V" + ignore_errors: true + register: netdata_installed_st + changed_when: false + vars: + prefix: "{{ netdata_prefix | ternary(netdata_prefix~'/bin/', '') }}" + +- name: Uninstall netdata + include: uninstall.yml + when: + - netdata_uninstall_before is defined + - netdata_uninstall_before | bool + +- name: Install netdata + shell: + cmd: bash <(curl -Ss https://my-netdata.io/{{ netdata_installer }}.sh) --dont-wait {{ netdata_install_options }} + args: + executable: /bin/bash + when: + - netdata_installed_st is failed or netdata_force_install or netdata_uninstall_before + +- name: Configure netdata + template: + src: netdata.conf.j2 + dest: "{{ netdata_prefix }}/etc/netdata/netdata.conf" + owner: root + group: root + mode: 0644 + notify: restart netdata + +- name: Configure streaming + template: + src: stream.conf.j2 + dest: "{{ netdata_prefix }}/etc/netdata/stream.conf" + owner: root + group: netdata + mode: 0640 + when: + - netdata_streaming_configuration is defined + - netdata_streaming_configuration | count > 0 + notify: restart netdata + +- name: Configure netdata alarm notifications + template: + dest: "{{ netdata_prefix }}/etc/netdata/health_alarm_notify.conf" + src: "health_alarm_notify.conf.j2" + owner: netdata + group: root + mode: 0640 + when: + - netdata_alarm_notify_configs is defined + - netdata_alarm_notify_configs | count > 0 + notify: restart netdata diff --git a/tasks/uninstall.yml b/tasks/uninstall.yml new file mode 100644 index 0000000..1b2c4b9 --- /dev/null +++ b/tasks/uninstall.yml @@ -0,0 +1,13 @@ +- name: Check uninstaller presence + stat: + path: "{{ item }}/netdata-uninstaller.sh" + loop: + - /usr/libexec/netdata + - /opt/netdata/usr/libexec/netdata + register: uninstaller_presence + +- name: Uninstall + command: "{{ item }} --yes --force" # noqa 301 + loop: "{{ uninstallers }}" + vars: + uninstallers: "{{ uninstaller_presence.results | selectattr('stat.exists') | map(attribute='invocation.module_args.path') | list }}" -- cgit v1.2.3