init
This commit is contained in:
19
tasks/alerta.yml
Normal file
19
tasks/alerta.yml
Normal file
@ -0,0 +1,19 @@
|
||||
---
|
||||
- name: Add alerta web hook
|
||||
no_log: true
|
||||
lineinfile:
|
||||
line: ALERTA_WEBHOOK_URL="{{ netdata_alerta_web_hook_url }}"
|
||||
dest: /etc/netdata/health_alarm_notify.conf
|
||||
regexp: "^ALERTA_WEBHOOK_URL"
|
||||
|
||||
- name: Add alerta API key
|
||||
lineinfile:
|
||||
line: ALERTA_API_KEY="{{ netdata_alerta_api_key }}"
|
||||
dest: /etc/netdata/health_alarm_notify.conf
|
||||
regexp: "^ALERTA_API_KEY"
|
||||
|
||||
- name: Add alerta recipient
|
||||
lineinfile:
|
||||
line: DEFAULT_RECIPIENT_ALERTA="{{ netdata_alerta_recipient }}"
|
||||
dest: /etc/netdata/health_alarm_notify.conf
|
||||
regexp: "^DEFAULT_RECIPIENT_ALERTA"
|
||||
43
tasks/main.yml
Normal file
43
tasks/main.yml
Normal file
@ -0,0 +1,43 @@
|
||||
---
|
||||
- name: Ensure mandatory variables are configured
|
||||
assert:
|
||||
that: "{{ item }} is defined"
|
||||
fail_msg: "You must define the '{{ item }}' variable"
|
||||
with_items:
|
||||
- netdata_alerta_api_key
|
||||
- netdata_alerta_recipient
|
||||
- netdata_alerta_web_hook_url
|
||||
|
||||
- name: Check if netdata installation present
|
||||
stat:
|
||||
path: /etc/netdata/.environment
|
||||
register: netdata_install
|
||||
|
||||
- name: Download the installer script
|
||||
get_url:
|
||||
url: https://my-netdata.io/kickstart.sh
|
||||
dest: /tmp/netdata-kickstart.sh
|
||||
mode: a+x
|
||||
force: true
|
||||
when: not netdata_install.stat.exists or netdata_upgrade
|
||||
|
||||
- name: Run netdata installer script (install/ugrade as required)
|
||||
command: |
|
||||
bash /tmp/netdata-kickstart.sh
|
||||
--dont-wait
|
||||
--stable-channel
|
||||
--disable-cloud
|
||||
when: not netdata_install.stat.exists or netdata_upgrade
|
||||
notify: Restart netdata
|
||||
|
||||
- name: Ensure health_alarm_notify script is in /etc/netdata
|
||||
copy:
|
||||
src: /usr/lib/netdata/conf.d/health_alarm_notify.conf
|
||||
dest: /etc/netdata/health_alarm_notify.conf
|
||||
remote_src: true
|
||||
force: false
|
||||
when: not netdata_install.stat.exists
|
||||
|
||||
- name: Include alerta configuration tasks
|
||||
include: alerta.yml
|
||||
when: not netdata_install.stat.exists
|
||||
Reference in New Issue
Block a user