Bootstrap telegraf role

This commit is contained in:
Wilfried OLLIVIER 2019-07-10 17:10:35 +02:00
commit c7da2cb3a0
13 changed files with 7205 additions and 0 deletions

13
LICENCE Normal file
View File

@ -0,0 +1,13 @@
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2019 Wilfried OLLIVIER <wollivier@fdn.fr>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.

43
README.md Normal file
View File

@ -0,0 +1,43 @@
galaxy-telegraf
===============
Install Telegraf on Debian
Requirements
------------
An InfluxDB service up and running
Role Variables
--------------
- db_name: influx db name
- db_user: influx db username
- db_pass: influx db password
- influx_host: influx host
- influx_port: influx db port
- influx_host: influx db host
Dependencies
------------
None
Example Playbook
----------------
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
- hosts: servers
roles:
- role: galaxy-telegraf
Run tests
---------
Needs galaxy-vagrant to run tests
Ensure galaxy-vagrant is up
ansible-playbook -i tests/inventory tests/test.yml

9
defaults/main.yml Normal file
View File

@ -0,0 +1,9 @@
---
db_name: telegraf
db_user: telegraf
db_pass: not24get
influx_host: localhost
influx_proto: http
influx_port: 8086

6
handlers/main.yml Normal file
View File

@ -0,0 +1,6 @@
---
- name: reload telegraf
systemd:
name: telegraf
state: restarted

21
meta/main.yml Normal file
View File

@ -0,0 +1,21 @@
galaxy_info:
author: Wilfried OLLIVIER
description: Galaxy role to install telegraf with basic config on Debian
company: none
license: WTFPL
min_ansible_version: 2.4
platforms:
- name: Debian
versions:
- Stretch
- Buster
galaxy_tags:
- telegraf
- debian
- timeseries
dependencies: []

61
tasks/main.yml Normal file
View File

@ -0,0 +1,61 @@
---
# https://docs.influxdata.com/telegraf/v1.11/introduction/installation/
- name: Ensure apt-transport-https
apt:
name: apt-transport-https
state: present
update_cache: yes
- name: Ensure python dependencies
apt:
name: [ 'python-requests', 'python-pip' ]
state: present
- name: Ensure Influx Data signing key
apt_key:
url: "{{ influx.repo }}"
state: present
- name: Ensure Influx Data repo
apt_repository:
repo: deb https://repos.influxdata.com/debian {{ ansible_distribution_release }} stable
state: present
filename: influxdata
- name: Ensure Telegraf pkg
apt:
name: telegraf
update_cache: yes
state: present
- name: Push Telegraf config
template:
src: telegraf.conf.j2
dest: /etc/telegraf/telegraf.conf
notify: reload telegraf
- name: Push Telegraf base input config
template:
src: inputs/input.base.conf.j2
dest: /etc/telegraf/telegraf.d/input.base.conf
notify: reload telegraf
- name: Is Docker running ?
service_facts:
- name: Push Telegraf docker input config if needed
template:
src: inputs/input.docker.conf.j2
dest: /etc/telegraf/telegraf.d/input.docker.conf
notify: reload telegraf
when: "'docker' in services"
- name: Ensure Telegraf can access Docker socket
user: name=telegraf
group=telegraf
groups=docker
append=yes
when: "'docker' in services"

View File

@ -0,0 +1,80 @@
###############################################################################
# INPUT PLUGINS #
###############################################################################
# Read metrics about cpu usage
[[inputs.cpu]]
## Whether to report per-cpu stats or not
percpu = true
## Whether to report total system cpu stats or not
totalcpu = true
## If true, collect raw CPU time metrics.
collect_cpu_time = false
## If true, compute and report the sum of all non-idle CPU states.
report_active = false
# Read metrics about disk usage by mount point
[[inputs.disk]]
## By default stats will be gathered for all mount points.
## Set mount_points will restrict the stats to only the specified mount points.
# mount_points = ["/"]
## Ignore mount points by filesystem type.
ignore_fs = ["tmpfs", "devtmpfs", "devfs", "iso9660", "overlay", "aufs", "squashfs"]
# Read metrics about disk IO by device
[[inputs.diskio]]
## By default, telegraf will gather stats for all devices including
## disk partitions.
## Setting devices will restrict the stats to the specified devices.
# devices = ["sda", "sdb", "vd*"]
## Uncomment the following line if you need disk serial numbers.
# skip_serial_number = false
#
## On systems which support it, device metadata can be added in the form of
## tags.
## Currently only Linux is supported via udev properties. You can view
## available properties for a device by running:
## 'udevadm info -q property -n /dev/sda'
## Note: Most, but not all, udev properties can be accessed this way. Properties
## that are currently inaccessible include DEVTYPE, DEVNAME, and DEVPATH.
# device_tags = ["ID_FS_TYPE", "ID_FS_USAGE"]
#
## Using the same metadata source as device_tags, you can also customize the
## name of the device via templates.
## The 'name_templates' parameter is a list of templates to try and apply to
## the device. The template may contain variables in the form of '$PROPERTY' or
## '${PROPERTY}'. The first template which does not contain any variables not
## present for the device is used as the device name tag.
## The typical use case is for LVM volumes, to get the VG/LV name instead of
## the near-meaningless DM-0 name.
# name_templates = ["$ID_FS_LABEL","$DM_VG_NAME/$DM_LV_NAME"]
# Get kernel statistics from /proc/stat
[[inputs.kernel]]
# no configuration
# Read metrics about memory usage
[[inputs.mem]]
# no configuration
# Get the number of processes and group them by status
[[inputs.processes]]
# no configuration
# Read metrics about swap memory usage
[[inputs.swap]]
# no configuration
# Read metrics about system load & uptime
[[inputs.system]]
## Uncomment to remove deprecated metrics.
# fielddrop = ["uptime_format"]

View File

@ -0,0 +1,54 @@
###############################################################################
# INPUT PLUGINS #
###############################################################################
# Read metrics about docker containers
[[inputs.docker]]
## Docker Endpoint
## To use TCP, set endpoint = "tcp://[ip]:[port]"
## To use environment variables (ie, docker-machine), set endpoint = "ENV"
endpoint = "unix:///var/run/docker.sock"
## Set to true to collect Swarm metrics(desired_replicas, running_replicas)
## Note: configure this in one of the manager nodes in a Swarm cluster.
## configuring in multiple Swarm managers results in duplication of metrics.
gather_services = false
## Only collect metrics for these containers. Values will be appended to
## container_name_include.
## Deprecated (1.4.0), use container_name_include
# container_names = []
## Containers to include and exclude. Collect all if empty. Globs accepted.
container_name_include = []
container_name_exclude = []
## Container states to include and exclude. Globs accepted.
## When empty only containers in the "running" state will be captured.
# container_state_include = []
# container_state_exclude = []
## Timeout for docker list, info, and stats commands
timeout = "5s"
## Whether to report for each container per-device blkio (8:0, 8:1...) and
## network (eth0, eth1, ...) stats or not
perdevice = true
## Whether to report for each container total blkio and network stats or not
total = false
## docker labels to include and exclude as tags. Globs accepted.
## Note that an empty array for both will include all labels as tags
docker_label_include = []
docker_label_exclude = []
## Which environment variables should we use as a tag
tag_env = ["JAVA_HOME", "HEAP_SIZE"]
## Optional TLS Config
# tls_ca = "/etc/telegraf/ca.pem"
# tls_cert = "/etc/telegraf/cert.pem"
# tls_key = "/etc/telegraf/key.pem"
## Use TLS but skip chain & host verification
# insecure_skip_verify = false

1264
templates/telegraf.conf.j2 Normal file

File diff suppressed because it is too large Load Diff

5644
templates/telegraf.conf.orig Normal file

File diff suppressed because it is too large Load Diff

1
tests/inventory Normal file
View File

@ -0,0 +1 @@
galaxy-vagrant.example.com

5
tests/test.yml Normal file
View File

@ -0,0 +1,5 @@
---
- hosts: galaxy-vagrant.example.com
remote_user: root
roles:
- role: ../galaxy-telegraf

4
vars/main.yml Normal file
View File

@ -0,0 +1,4 @@
---
influx:
repo: https://repos.influxdata.com/influxdb.key