mirror of
https://github.com/luzifer-ansible/netdata.git
synced 2024-11-08 13:50:01 +00:00
Initial version
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
commit
d0a6edd67c
5 changed files with 238 additions and 0 deletions
15
README.md
Normal file
15
README.md
Normal file
|
@ -0,0 +1,15 @@
|
|||
# Luzifer-Ansible / netdata
|
||||
|
||||
This role installs a systemd service running [netdata](https://github.com/firehol/netdata) using Docker and my [Docker image](https://quay.io/luzifer/netdata) for it.
|
||||
|
||||
## Usage
|
||||
|
||||
```yaml
|
||||
roles:
|
||||
- role: netdata
|
||||
config:
|
||||
PUSHOVER_APP_TOKEN: 'mytoken'
|
||||
DEFAULT_RECIPIENT_PUSHOVER: 'myuser'
|
||||
```
|
||||
|
||||
(For configuration values see the [original repositories](https://github.com/luzifer-docker/netdata) README file!)
|
5
defaults/main.yml
Normal file
5
defaults/main.yml
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
|
||||
config: {}
|
||||
hostname: '{{ ansible_hostname }}'
|
||||
version: latest
|
134
meta/main.yml
Normal file
134
meta/main.yml
Normal file
|
@ -0,0 +1,134 @@
|
|||
---
|
||||
galaxy_info:
|
||||
author: Knut Ahlers
|
||||
description: Install netdata using Docker container on host
|
||||
# If the issue tracker for your role is not on github, uncomment the
|
||||
# next line and provide a value
|
||||
# issue_tracker_url: http://example.com/issue/tracker
|
||||
# Some suggested licenses:
|
||||
# - BSD (default)
|
||||
# - MIT
|
||||
# - GPLv2
|
||||
# - GPLv3
|
||||
# - Apache
|
||||
# - CC-BY
|
||||
license: Apache
|
||||
min_ansible_version: 2.3
|
||||
#
|
||||
# Below are all platforms currently available. Just uncomment
|
||||
# the ones that apply to your role. If you don't see your
|
||||
# platform on this list, let us know and we'll get it added!
|
||||
#
|
||||
platforms:
|
||||
#- name: EL
|
||||
# versions:
|
||||
# - all
|
||||
# - 5
|
||||
# - 6
|
||||
# - 7
|
||||
#- name: GenericUNIX
|
||||
# versions:
|
||||
# - all
|
||||
# - any
|
||||
#- name: Fedora
|
||||
# versions:
|
||||
# - all
|
||||
# - 16
|
||||
# - 17
|
||||
# - 18
|
||||
# - 19
|
||||
# - 20
|
||||
# - 21
|
||||
# - 22
|
||||
#- name: SmartOS
|
||||
# versions:
|
||||
# - all
|
||||
# - any
|
||||
#- name: opensuse
|
||||
# versions:
|
||||
# - all
|
||||
# - 12.1
|
||||
# - 12.2
|
||||
# - 12.3
|
||||
# - 13.1
|
||||
# - 13.2
|
||||
#- name: Amazon
|
||||
# versions:
|
||||
# - all
|
||||
# - 2013.03
|
||||
# - 2013.09
|
||||
#- name: GenericBSD
|
||||
# versions:
|
||||
# - all
|
||||
# - any
|
||||
#- name: FreeBSD
|
||||
# versions:
|
||||
# - all
|
||||
# - 8.0
|
||||
# - 8.1
|
||||
# - 8.2
|
||||
# - 8.3
|
||||
# - 8.4
|
||||
# - 9.0
|
||||
# - 9.1
|
||||
# - 9.1
|
||||
# - 9.2
|
||||
- name: Ubuntu
|
||||
versions:
|
||||
# - all
|
||||
# - lucid
|
||||
# - maverick
|
||||
# - natty
|
||||
# - oneiric
|
||||
# - precise
|
||||
# - quantal
|
||||
# - raring
|
||||
# - saucy
|
||||
# - trusty
|
||||
# - utopic
|
||||
# - vivid
|
||||
- xenial
|
||||
#- name: SLES
|
||||
# versions:
|
||||
# - all
|
||||
# - 10SP3
|
||||
# - 10SP4
|
||||
# - 11
|
||||
# - 11SP1
|
||||
# - 11SP2
|
||||
# - 11SP3
|
||||
#- name: GenericLinux
|
||||
# versions:
|
||||
# - all
|
||||
# - any
|
||||
#- name: Debian
|
||||
# versions:
|
||||
# - all
|
||||
# - etch
|
||||
# - jessie
|
||||
# - lenny
|
||||
# - squeeze
|
||||
# - wheezy
|
||||
#
|
||||
# Below are all categories currently available. Just as with
|
||||
# the platforms above, uncomment those that apply to your role.
|
||||
#
|
||||
categories:
|
||||
#- cloud
|
||||
#- cloud:ec2
|
||||
#- cloud:gce
|
||||
#- cloud:rax
|
||||
#- clustering
|
||||
#- database
|
||||
#- database:nosql
|
||||
#- database:sql
|
||||
#- development
|
||||
#- monitoring
|
||||
#- networking
|
||||
#- packaging
|
||||
- system
|
||||
#- web
|
||||
dependencies: []
|
||||
# List your role dependencies here, one per line.
|
||||
# Be sure to remove the '[]' above if you add dependencies
|
||||
# to this list.
|
79
tasks/main.yml
Normal file
79
tasks/main.yml
Normal file
|
@ -0,0 +1,79 @@
|
|||
---
|
||||
|
||||
- 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: |
|
||||
# {{ ansible_managed }}
|
||||
|
||||
[global]
|
||||
hostname = {{ hostname }}
|
||||
register: netdata_conf
|
||||
|
||||
- name: Set environment variables
|
||||
template:
|
||||
dest: /etc/netdata/environment
|
||||
src: environment.j2
|
||||
register: configuration
|
||||
|
||||
- name: Install netdata systemctl service
|
||||
copy:
|
||||
dest: /etc/systemd/system/netdata.service
|
||||
content: |
|
||||
# {{ ansible_managed }}
|
||||
|
||||
[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
|
5
templates/environment.j2
Normal file
5
templates/environment.j2
Normal file
|
@ -0,0 +1,5 @@
|
|||
# {{ ansible_managed }}
|
||||
|
||||
{% for k,v in config.items() %}
|
||||
{{k}}={{v}}
|
||||
{% endfor %}
|
Loading…
Reference in a new issue