mirror of
https://github.com/luzifer-ansible/netdata.git
synced 2024-11-08 13:50:01 +00:00
76 lines
2 KiB
YAML
76 lines
2 KiB
YAML
---
|
|
|
|
- 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
|
|
mode: 0600
|
|
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
|
|
|
|
EnvironmentFile=-/etc/netdata/environment
|
|
|
|
ExecStartPre=/usr/bin/docker pull quay.io/luzifer/netdata
|
|
ExecStartPre=-/usr/bin/docker rm -f netdata
|
|
|
|
ExecStart=/usr/bin/docker run -d --cap-add SYS_PTRACE \
|
|
-v /proc:/host/proc:ro \
|
|
-v /sys:/host/sys:ro \
|
|
-v /etc/netdata:/override:ro \
|
|
-v /var/run/docker.sock:/var/run/docker.sock \
|
|
-p 19999:19999 \
|
|
--name=netdata \
|
|
quay.io/luzifer/netdata:{{ version }}
|
|
|
|
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
|
|
when: configuration.changed or netdata_conf.changed
|