2017-08-31 11:38:01 +00:00
|
|
|
---
|
|
|
|
|
|
|
|
- name: Ensure directories required
|
|
|
|
file:
|
|
|
|
dest: '{{ item }}'
|
|
|
|
state: directory
|
|
|
|
with_items:
|
|
|
|
- /etc/netdata
|
|
|
|
- /etc/netdata/conf.d
|
|
|
|
- /etc/netdata/charts.d
|
|
|
|
- /etc/netdata/node.d
|
|
|
|
- /etc/netdata/plugins.d
|
|
|
|
- /etc/netdata/python.d
|
|
|
|
|
|
|
|
- name: Set system hostname as netdata hostname
|
|
|
|
copy:
|
|
|
|
dest: /etc/netdata/conf.d/netdata.conf
|
|
|
|
content: |
|
|
|
|
[global]
|
|
|
|
hostname = {{ hostname }}
|
|
|
|
register: netdata_conf
|
|
|
|
|
|
|
|
- name: Set environment variables
|
|
|
|
template:
|
|
|
|
dest: /etc/netdata/environment
|
|
|
|
src: environment.j2
|
2017-08-31 12:09:45 +00:00
|
|
|
mode: 0600
|
2017-08-31 11:38:01 +00:00
|
|
|
register: configuration
|
|
|
|
|
|
|
|
- name: Install netdata systemctl service
|
|
|
|
copy:
|
|
|
|
dest: /etc/systemd/system/netdata.service
|
|
|
|
content: |
|
|
|
|
[Unit]
|
|
|
|
Description=Netdata metrics daemon
|
|
|
|
After=docker.service
|
|
|
|
Requires=docker.service
|
|
|
|
|
|
|
|
[Service]
|
|
|
|
RemainAfterExit=yes
|
2017-09-18 11:30:46 +00:00
|
|
|
TimeoutSec=infinity
|
2017-08-31 11:38:01 +00:00
|
|
|
|
2018-11-30 15:45:11 +00:00
|
|
|
ExecStartPre=/usr/bin/docker pull luzifer/netdata:{{ version }}
|
2017-08-31 11:38:01 +00:00
|
|
|
ExecStartPre=-/usr/bin/docker rm -f netdata
|
|
|
|
|
|
|
|
ExecStart=/usr/bin/docker run -d --cap-add SYS_PTRACE \
|
2017-09-01 14:20:45 +00:00
|
|
|
--security-opt=apparmor:unconfined \
|
2017-08-31 11:38:01 +00:00
|
|
|
-v /proc:/host/proc:ro \
|
|
|
|
-v /sys:/host/sys:ro \
|
|
|
|
-v /etc/netdata:/override:ro \
|
|
|
|
-v /var/run/docker.sock:/var/run/docker.sock \
|
2017-08-31 13:58:39 +00:00
|
|
|
-v /var/lib/netdata:/var/lib/netdata \
|
2017-08-31 11:38:01 +00:00
|
|
|
-p 19999:19999 \
|
2017-08-31 12:26:05 +00:00
|
|
|
--env-file=/etc/netdata/environment \
|
2017-08-31 11:38:01 +00:00
|
|
|
--name=netdata \
|
2018-11-30 15:45:11 +00:00
|
|
|
luzifer/netdata:{{ version }}
|
2017-08-31 11:38:01 +00:00
|
|
|
|
|
|
|
ExecReload=/usr/bin/docker restart netdata
|
|
|
|
|
|
|
|
ExecStop=/usr/bin/docker stop netdata
|
|
|
|
|
|
|
|
[Install]
|
|
|
|
WantedBy=multi-user.target
|
|
|
|
register: service
|
|
|
|
|
|
|
|
- name: Activate netdata service
|
|
|
|
systemd:
|
|
|
|
daemon_reload: yes
|
|
|
|
enabled: yes
|
|
|
|
name: netdata.service
|
|
|
|
state: restarted
|
|
|
|
when: service.changed
|
|
|
|
|
|
|
|
- name: Reload configuration when required
|
|
|
|
systemd:
|
|
|
|
name: netdata.service
|
|
|
|
state: reloaded
|
2017-09-18 14:44:12 +00:00
|
|
|
when: (configuration.changed or netdata_conf.changed) and not service.changed
|