aboutsummaryrefslogtreecommitdiffhomepage
path: root/tasks
diff options
context:
space:
mode:
Diffstat (limited to 'tasks')
-rw-r--r--tasks/main.yml67
-rw-r--r--tasks/uninstall.yml13
2 files changed, 80 insertions, 0 deletions
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 @@
1---
2- name: Install requirements (Debian family)
3 apt:
4 name: curl
5 state: present
6 when: ansible_os_family == 'Debian'
7
8- name: Install requirements (Redhat family)
9 yum:
10 name: curl
11 state: present
12 when: ansible_os_family == 'RedHat'
13
14- name: Check if netdata is installed
15 command: "{{ prefix }}netdata -V"
16 ignore_errors: true
17 register: netdata_installed_st
18 changed_when: false
19 vars:
20 prefix: "{{ netdata_prefix | ternary(netdata_prefix~'/bin/', '') }}"
21
22- name: Uninstall netdata
23 include: uninstall.yml
24 when:
25 - netdata_uninstall_before is defined
26 - netdata_uninstall_before | bool
27
28- name: Install netdata
29 shell:
30 cmd: bash <(curl -Ss https://my-netdata.io/{{ netdata_installer }}.sh) --dont-wait {{ netdata_install_options }}
31 args:
32 executable: /bin/bash
33 when:
34 - netdata_installed_st is failed or netdata_force_install or netdata_uninstall_before
35
36- name: Configure netdata
37 template:
38 src: netdata.conf.j2
39 dest: "{{ netdata_prefix }}/etc/netdata/netdata.conf"
40 owner: root
41 group: root
42 mode: 0644
43 notify: restart netdata
44
45- name: Configure streaming
46 template:
47 src: stream.conf.j2
48 dest: "{{ netdata_prefix }}/etc/netdata/stream.conf"
49 owner: root
50 group: netdata
51 mode: 0640
52 when:
53 - netdata_streaming_configuration is defined
54 - netdata_streaming_configuration | count > 0
55 notify: restart netdata
56
57- name: Configure netdata alarm notifications
58 template:
59 dest: "{{ netdata_prefix }}/etc/netdata/health_alarm_notify.conf"
60 src: "health_alarm_notify.conf.j2"
61 owner: netdata
62 group: root
63 mode: 0640
64 when:
65 - netdata_alarm_notify_configs is defined
66 - netdata_alarm_notify_configs | count > 0
67 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 @@
1- name: Check uninstaller presence
2 stat:
3 path: "{{ item }}/netdata-uninstaller.sh"
4 loop:
5 - /usr/libexec/netdata
6 - /opt/netdata/usr/libexec/netdata
7 register: uninstaller_presence
8
9- name: Uninstall
10 command: "{{ item }} --yes --force" # noqa 301
11 loop: "{{ uninstallers }}"
12 vars:
13 uninstallers: "{{ uninstaller_presence.results | selectattr('stat.exists') | map(attribute='invocation.module_args.path') | list }}"