netdata/tasks/main.yml
Knut Ahlers 9ed3291fd3
Fix: Pull same version as later being used
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2017-09-18 13:24:19 +02:00

77 lines
2.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
ExecStartPre=/usr/bin/docker pull quay.io/luzifer/netdata:{{ version }}
ExecStartPre=-/usr/bin/docker rm -f netdata
ExecStart=/usr/bin/docker run -d --cap-add SYS_PTRACE \
--security-opt=apparmor:unconfined \
-v /proc:/host/proc:ro \
-v /sys:/host/sys:ro \
-v /etc/netdata:/override:ro \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /var/lib/netdata:/var/lib/netdata \
-p 19999:19999 \
--env-file=/etc/netdata/environment \
--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