mirror of
https://github.com/dj-wasabi/ansible-telegraf.git
synced 2025-07-17 08:46:37 +00:00
Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
a733de5695 | |||
f28ba37db5 | |||
54f2b75af5 | |||
bbcd52e32f | |||
e2205aa7d8 | |||
66e20cd7f6 | |||
720e9c94da | |||
ec993c2066 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
||||
.kitchen/
|
||||
.kitchen.local.yml
|
||||
.idea/
|
||||
pmip
|
||||
|
15
.travis.yml
Normal file
15
.travis.yml
Normal file
@ -0,0 +1,15 @@
|
||||
---
|
||||
language: python
|
||||
python: "2.7"
|
||||
before_install:
|
||||
- sudo apt-get update -qq
|
||||
- sudo apt-get install -qq python-apt python-pycurl
|
||||
install:
|
||||
- pip install ansible==1.9.4
|
||||
- echo -e 'localhost ansible_connection=local' > test/inventory
|
||||
- echo -e '[defaults]\nroles_path = ../\nhostfile = ./test/inventory' > ansible.cfg
|
||||
script:
|
||||
- ansible-playbook test/integration/default.yml --syntax-check
|
||||
- ansible-playbook test/integration/default.yml --connection=local --sudo
|
||||
notifications:
|
||||
webhooks: https://galaxy.ansible.com/api/v1/notifications/
|
12
CHANGELOG.md
12
CHANGELOG.md
@ -5,6 +5,18 @@ Below an overview of all changes in the releases.
|
||||
|
||||
Version (Release date)
|
||||
|
||||
0.4.0 (2016-02-05)
|
||||
|
||||
* Fixed test for test-kitchen
|
||||
* Added travis-ci test for testing default installation when PR is made
|
||||
* Fixed Download url for Debian
|
||||
* Removed default entry for telegraf_plugins_extra
|
||||
|
||||
0.3.0 (2016-01-13)
|
||||
|
||||
* Made it work with telegraf 0.10.0
|
||||
* Default installation: 0.10.0
|
||||
|
||||
0.2.0 (2015-11-14)
|
||||
|
||||
* Fixed kitchen test setup
|
||||
|
12
README.md
12
README.md
@ -1,6 +1,10 @@
|
||||
dj-wasabi.telegraf
|
||||
=========
|
||||
|
||||
Build status:
|
||||
|
||||
[](https://travis-ci.org/dj-wasabi/ansible-telegraf)
|
||||
|
||||
This role will install and configure telegraf.
|
||||
|
||||
Telegraf is an agent written in Go for collecting metrics from the system it's running on, or from other services, and writing them into InfluxDB.
|
||||
@ -19,10 +23,12 @@ Role Variables
|
||||
|
||||
The following parameters can be set for the Telegraf agent:
|
||||
|
||||
* `telegraf_agent_version`: The version of Telegraf to install. Default: `0.2.0`
|
||||
* `telegraf_agent_version`: The version of Telegraf to install. Default: `0.10.0`
|
||||
* `telegraf_agent_interval`: The interval configured for sending data to the server. Default: `10`
|
||||
* `telegraf_agent_debug`: Setting the Telegraf in debug mode. Default: `False`
|
||||
|
||||
* `telegraf_agent_round_interval`: Rounds collection interval to 'interval' Default: True
|
||||
* `telegraf_agent_flush_interval`: Default data flushing interval for all outputs. Default: 10
|
||||
* `telegraf_agent_flush_jitter`: Jitter the flush interval by a random amount. Default: 0
|
||||
|
||||
You can set tags for the host running telegraf:
|
||||
|
||||
@ -35,7 +41,7 @@ Specifying an output. The default is set to localhost, you'll have to specify th
|
||||
telegraf_agent_output:
|
||||
- type: influxdb
|
||||
config:
|
||||
- url = "http://localhost:8086"
|
||||
- urls = ["http://localhost:8086"]
|
||||
- database = "telegraf"
|
||||
|
||||
The config will be printed line by line into the configuration, so you could also use:
|
||||
|
@ -1,17 +1,21 @@
|
||||
---
|
||||
# defaults file for ansible-telegraf
|
||||
|
||||
telegraf_agent_version: 0.2.0
|
||||
telegraf_agent_version: 0.10.1
|
||||
telegraf_agent_interval: 10
|
||||
telegraf_agent_debug: False
|
||||
telegraf_agent_round_interval: True
|
||||
telegraf_agent_flush_interval: 10
|
||||
telegraf_agent_flush_jitter: 0
|
||||
|
||||
telegraf_agent_tags:
|
||||
|
||||
telegraf_agent_output:
|
||||
- type: influxdb
|
||||
config:
|
||||
- url = "http://localhost:8086"
|
||||
- urls = ["http://localhost:8086"]
|
||||
- database = "telegraf"
|
||||
- precision = "s"
|
||||
|
||||
telegraf_plugins_default:
|
||||
- plugin: cpu
|
||||
@ -26,7 +30,3 @@ telegraf_plugins_default:
|
||||
- plugin: netstat
|
||||
|
||||
telegraf_plugins_extra:
|
||||
- plugin: procstat
|
||||
specifications:
|
||||
- prefix = "" # optional string to prefix measurements
|
||||
- exe = "java" # the name as pgrep can find
|
||||
|
@ -2,13 +2,13 @@
|
||||
|
||||
- name: "Fetch telegraf installation package | Debian"
|
||||
action: get_url
|
||||
url=http://get.influxdb.org/telegraf/telegraf-{{ telegraf_agent_version }}_amd64.deb
|
||||
dest=/tmp/telegraf_{{ telegraf_agent_version }}_amd64.deb
|
||||
url=http://get.influxdb.org/telegraf/telegraf_{{ telegraf_agent_version }}-1_amd64.deb
|
||||
dest=/tmp/telegraf_{{ telegraf_agent_version }}-1_amd64.deb
|
||||
mode=0440
|
||||
|
||||
- name: "Install telegraf package | Debian"
|
||||
action: apt
|
||||
deb=/tmp/telegraf_{{ telegraf_agent_version }}_amd64.deb
|
||||
deb=/tmp/telegraf_{{ telegraf_agent_version }}-1_amd64.deb
|
||||
state=installed
|
||||
notify: "Restart Telegraf"
|
||||
sudo: yes
|
||||
|
@ -9,12 +9,28 @@
|
||||
include: "Debian.yml"
|
||||
when: ansible_os_family == "Debian"
|
||||
|
||||
- name: "Copy the template"
|
||||
- name: "Set fact by remove the dots from version"
|
||||
action: set_fact
|
||||
telegraf_ver="{{ telegraf_agent_version.replace('.','') }}"
|
||||
|
||||
- name: "Copy the template for versions < 0.10.0"
|
||||
action: template
|
||||
src=etc-opt-telegraf-telegraf.conf.j2
|
||||
dest=/etc/opt/telegraf/telegraf.conf
|
||||
owner=root
|
||||
group=root
|
||||
mode=644
|
||||
when: telegraf_ver < 100
|
||||
sudo: yes
|
||||
notify: "Restart Telegraf"
|
||||
|
||||
- name: "Copy the template for versions >= 0.10.0"
|
||||
action: template
|
||||
src=telegraf.conf.j2
|
||||
dest=/etc/telegraf/telegraf.conf
|
||||
owner=root
|
||||
group=root
|
||||
mode=644
|
||||
when: telegraf_ver >= 100
|
||||
sudo: yes
|
||||
notify: "Restart Telegraf"
|
||||
|
123
templates/telegraf.conf.j2
Normal file
123
templates/telegraf.conf.j2
Normal file
@ -0,0 +1,123 @@
|
||||
# Telegraf configuration
|
||||
|
||||
[tags]
|
||||
{% if telegraf_agent_tags is defined and telegraf_agent_tags is iterable %}
|
||||
{% for item in telegraf_agent_tags %}
|
||||
{{ item.tag_name }} = "{{ item.tag_value }}"
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
# Configuration for telegraf agent
|
||||
[agent]
|
||||
interval = "{{ telegraf_agent_interval }}s"
|
||||
debug = {{ telegraf_agent_debug | lower }}
|
||||
hostname = "{{ ansible_fqdn }}"
|
||||
round_interval = {{ telegraf_agent_round_interval | lower }}
|
||||
flush_interval = "{{ telegraf_agent_flush_interval }}s"
|
||||
flush_jitter = "{{ telegraf_agent_flush_jitter }}s"
|
||||
|
||||
###############################################################################
|
||||
# OUTPUTS #
|
||||
###############################################################################
|
||||
|
||||
{% if telegraf_agent_output is defined and telegraf_agent_output is iterable %}
|
||||
{% for item in telegraf_agent_output %}
|
||||
[[outputs.{{ item.type }}]]
|
||||
{% for items in item.config %}
|
||||
{{ items }}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
###############################################################################
|
||||
# INPUTS #
|
||||
###############################################################################
|
||||
|
||||
{% if telegraf_plugins_default is defined and telegraf_plugins_default is iterable %}
|
||||
{% for item in telegraf_plugins_default %}
|
||||
[[inputs.{{ item.plugin }}]]
|
||||
{% if item.interval is defined %}
|
||||
interval = "{{ item.interval }}s"
|
||||
{% endif %}
|
||||
{% if item.config is defined and item.config is iterable %}
|
||||
{% for items in item.config %}
|
||||
{{ items }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if item.tagpass is defined and item.tagpass is iterable %}
|
||||
[{{ item.plugin }}.tagpass]
|
||||
{% for items in item.tagpass %}
|
||||
{{ items }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if item.tagdrop is defined and item.tagdrop is iterable %}
|
||||
[{{ item.plugin }}.tagdrop]
|
||||
{% for items in item.tagdrop %}
|
||||
{{ items }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if item.pass is defined and item.pass is iterable %}
|
||||
[{{ item.plugin }}.pass]
|
||||
{% for items in item.pass %}
|
||||
{{ items }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if item.drop is defined and item.drop is iterable %}
|
||||
[{{ item.plugin }}.drop]
|
||||
{% for items in item.drop %}
|
||||
{{ items }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if item.specifications is defined and item.specifications is iterable %}
|
||||
[[{{item.plugin}}.specifications]]
|
||||
{% for items in item.specifications %}
|
||||
{{ items }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
|
||||
{% if telegraf_plugins_extra is defined and telegraf_plugins_extra is iterable %}
|
||||
{% for item in telegraf_plugins_extra %}
|
||||
[[inputs.{{ item.plugin }}]]
|
||||
{% if item.interval is defined %}
|
||||
interval = "{{ item.interval }}s"
|
||||
{% endif %}
|
||||
{% if item.config is defined and item.config is iterable %}
|
||||
{% for items in item.config %}
|
||||
{{ items }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if item.tagpass is defined and item.tagpass is iterable %}
|
||||
[{{ item.plugin }}.tagpass]
|
||||
{% for items in item.tagpass %}
|
||||
{{ items }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if item.tagdrop is defined and item.tagdrop is iterable %}
|
||||
[{{ item.plugin }}.tagdrop]
|
||||
{% for items in item.tagdrop %}
|
||||
{{ items }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if item.pass is defined and item.pass is iterable %}
|
||||
[{{ item.plugin }}.pass]
|
||||
{% for items in item.pass %}
|
||||
{{ items }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if item.drop is defined and item.drop is iterable %}
|
||||
[{{ item.plugin }}.drop]
|
||||
{% for items in item.drop %}
|
||||
{{ items }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if item.specifications is defined and item.specifications is iterable %}
|
||||
[[{{item.plugin}}.specifications]]
|
||||
{% for items in item.specifications %}
|
||||
{{ items }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
@ -15,7 +15,7 @@ describe 'Telegraf Services' do
|
||||
end
|
||||
|
||||
describe 'Telegraf Configuration' do
|
||||
describe file('/etc/opt/telegraf/telegraf.conf') do
|
||||
describe file('/etc/telegraf/telegraf.conf') do
|
||||
it { should be_file}
|
||||
it { should be_owned_by 'root'}
|
||||
it { should be_grouped_into 'root'}
|
||||
|
Reference in New Issue
Block a user