Merge pull request #93 from dj-wasabi/download-from-influxdb

Updated to Telegraf 1.10.0;Different installation methods
This commit is contained in:
Werner Dijkerman
2019-03-11 07:26:45 +01:00
committed by GitHub
6 changed files with 77 additions and 10 deletions

View File

@ -49,13 +49,30 @@ There was an issue:
## Role Variables
### Overall variables
### Ansible role specific variables
The following parameters can be set for the Telegraf agent:
Specifying the version to be installed:
* `telegraf_agent_version`: The version of Telegraf to install. Default: `1.9.0`
* `telegraf_agent_package`: The name of the Telegraf package. Default: `telegraf`
* `telegraf_agent_version`: The version of Telegraf to install. Default: `1.10.0`
How `Telegraf` needs to be installed. There are 3 methods in getting `Telegraf` installed on the target host:
* Via the package manager, like `yum`, `apt` or `zypper` ("repo");
* Via a download from the `https://dl.influxdata.com/` site ("online");
* Already provided and is already available on the target host, but not yet installed/configured ("offline");
This can be configured by setting `telegraf_agent_package_method` to one of the appropriate values ( `repo`, `online` or `offline`).
#### Telegraf Package
These properties set in how and what package will be installed.
* `telegraf_agent_package`: The name of the Telegraf package to install. When `telegraf_agent_package_method` is set to `online` or `offline`, it needs to have the full path of the file. Example: `telegraf_agent_package: /tmp/telegraf.rpm`. Default: `telegraf_agent_package: telegraf`.
* `telegraf_agent_package_method`: The installation method to be used. Can choose between: `repo`, `offline` or `online`.
* `telegraf_agent_package_state`: If the package should be `present` or `latest`. When set to `latest`, `telegraf_agent_version` will be ignored. Default: `present`
### Telegraf agent process configuration.
* `telegraf_agent_interval`: The interval configured for sending data to the server. Default: `10`
* `telegraf_agent_debug`: Run Telegraf in debug mode. Default: `False`
* `telegraf_agent_round_interval`: Rounds collection interval to 'interval' Default: True
@ -70,7 +87,7 @@ The following parameters can be set for the Telegraf agent:
* `telegraf_agent_logfile`: The agent logfile name. Default: '' (means to log to stdout) (since v1.1)
* `telegraf_agent_omit_hostname`: Do no set the "host" tag in the agent. Default: `False` (since v1.1)
Docker specific role variables:
### Docker specific role variables:
* `telegraf_agent_docker`: Install Telegraf as a docker container. Default: `False`
* `telegraf_agent_docker_name`: Name of the docker container. Default: `telegraf`
@ -81,6 +98,9 @@ Docker specific role variables:
Full agent settings reference: [https://github.com/influxdata/telegraf/blob/master/docs/CONFIGURATION.md#agent-configuration](https://github.com/influxdata/telegraf/blob/master/docs/CONFIGURATION.md#agent-configuration).
## Extra information
### Setting tags
You can set tags for the host running telegraf:
telegraf_global_tags:
@ -129,7 +149,7 @@ More information: [https://github.com/influxdata/telegraf/blob/master/docs/FAQ.m
# Force host networking mode, so Docker Engine Host traffic metrics can be gathered.
telegraf_agent_docker_network_mode: host
# Force a specific image tag.
telegraf_agent_version: 1.9.5-alpine
telegraf_agent_version: 1.10.0-alpine
telegraf_plugins_default:
- plugin: cpu

View File

@ -1,9 +1,11 @@
---
# defaults file for ansible-telegraf
telegraf_agent_version: 1.9.5
telegraf_agent_version: 1.10.0
telegraf_agent_version_patch: 1
telegraf_agent_package: telegraf
telegraf_agent_package_path: /tmp
telegraf_agent_package_method: repo
telegraf_agent_package_state: present
telegraf_agent_hostname: "{{ ansible_fqdn }}"
telegraf_agent_interval: 10

View File

@ -57,6 +57,10 @@ provisioner:
lint:
name: ansible-lint
inventory:
host_vars:
telegraf-debian:
telegraf_agent_package: /tmp/telegraf_amd64.deb
telegraf_agent_package_method: online
group_vars:
all:
telegraf_agent_package_state: latest

View File

@ -4,6 +4,6 @@ extends: default
rules:
line-length:
max: 140
max: 180
level: warning
truthy: disable

View File

@ -6,6 +6,16 @@
when:
- telegraf_agent_package_state != "latest"
- name: "Debian | Set telegraf_agent_package_arch"
set_fact:
telegraf_agent_package_arch: "{{ ansible_architecture }}"
- name: "Debian | Set telegraf_agent_package_arch specific for x86_64"
set_fact:
telegraf_agent_package_arch: "amd64"
when:
- ansible_architecture == "x86_64"
- name: "Debian | Ensure the system can use the HTTPS transport for APT"
stat:
path: /usr/lib/apt/methods/https
@ -29,6 +39,8 @@
register: are_telegraf_dependencies_keys_installed
until: are_telegraf_dependencies_keys_installed is succeeded
become: yes
when:
- telegraf_agent_package_method == "repo"
- name: "Debian | Add Telegraf repository (using LSB)"
apt_repository:
@ -37,6 +49,7 @@
state: present
become: yes
when:
- telegraf_agent_package_method == "repo"
- ansible_lsb is defined
- ansible_lsb.codename is defined
@ -47,15 +60,34 @@
state: present
become: yes
when:
- telegraf_agent_package_method == "repo"
- ansible_lsb is not defined or ansible_lsb.codename is not defined
- name: "Debian | Download Telegraf package (online)"
get_url:
url: https://dl.influxdata.com/telegraf/releases/telegraf_{{ telegraf_agent_version }}-{{ telegraf_agent_version_patch }}_{{ telegraf_agent_package_arch }}.deb
dest: "{{ telegraf_agent_package }}"
when:
- telegraf_agent_package_method == "online"
- name: "Debian | Install Telegraf package"
apt:
name: "{{ telegraf_agent_package }}"
state: "{{ telegraf_agent_package_state }}"
cache_valid_time: 900
force: True
register: is_telegraf_package_installed
until: is_telegraf_package_installed is succeeded
notify: "Restart Telegraf"
become: yes
when:
- telegraf_agent_package_method == "repo"
- name: "Debian | Install Telegraf package"
apt:
deb: "{{ telegraf_agent_package }}"
state: "present"
register: is_telegraf_package_installed
until: is_telegraf_package_installed is succeeded
notify: "Restart Telegraf"
become: yes
when:
- telegraf_agent_package_method != "repo"

View File

@ -19,6 +19,15 @@
baseurl: "{{ telegraf_yum_baseurl[ansible_distribution|lower] | default(telegraf_yum_baseurl['default']) }}"
gpgcheck: yes
gpgkey: https://repos.influxdata.com/influxdb.key
when:
- telegraf_agent_package_method == "repo"
- name: "RedHat | Download Telegraf package (online)"
get_url:
url: https://dl.influxdata.com/telegraf/releases/telegraf-{{ telegraf_agent_version }}-{{ telegraf_agent_version_patch }}.{{ ansible_architecture }}.rpm
dest: "{{ telegraf_agent_package }}"
when:
- telegraf_agent_package_method == "online"
- name: "RedHat | Install Telegraf package"
package: