mirror of
https://github.com/dj-wasabi/ansible-telegraf.git
synced 2025-07-17 08:46:37 +00:00
Merge pull request #93 from dj-wasabi/download-from-influxdb
Updated to Telegraf 1.10.0;Different installation methods
This commit is contained in:
32
README.md
32
README.md
@ -49,13 +49,30 @@ There was an issue:
|
|||||||
|
|
||||||
## Role Variables
|
## 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_version`: The version of Telegraf to install. Default: `1.10.0`
|
||||||
* `telegraf_agent_package`: The name of the Telegraf package. Default: `telegraf`
|
|
||||||
|
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_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_interval`: The interval configured for sending data to the server. Default: `10`
|
||||||
* `telegraf_agent_debug`: Run Telegraf in debug mode. Default: `False`
|
* `telegraf_agent_debug`: Run Telegraf in debug mode. Default: `False`
|
||||||
* `telegraf_agent_round_interval`: Rounds collection interval to 'interval' Default: True
|
* `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_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)
|
* `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`: Install Telegraf as a docker container. Default: `False`
|
||||||
* `telegraf_agent_docker_name`: Name of the docker container. Default: `telegraf`
|
* `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).
|
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:
|
You can set tags for the host running telegraf:
|
||||||
|
|
||||||
telegraf_global_tags:
|
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.
|
# Force host networking mode, so Docker Engine Host traffic metrics can be gathered.
|
||||||
telegraf_agent_docker_network_mode: host
|
telegraf_agent_docker_network_mode: host
|
||||||
# Force a specific image tag.
|
# Force a specific image tag.
|
||||||
telegraf_agent_version: 1.9.5-alpine
|
telegraf_agent_version: 1.10.0-alpine
|
||||||
|
|
||||||
telegraf_plugins_default:
|
telegraf_plugins_default:
|
||||||
- plugin: cpu
|
- plugin: cpu
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
---
|
---
|
||||||
# defaults file for ansible-telegraf
|
# defaults file for ansible-telegraf
|
||||||
|
|
||||||
telegraf_agent_version: 1.9.5
|
telegraf_agent_version: 1.10.0
|
||||||
telegraf_agent_version_patch: 1
|
telegraf_agent_version_patch: 1
|
||||||
telegraf_agent_package: telegraf
|
telegraf_agent_package: telegraf
|
||||||
|
telegraf_agent_package_path: /tmp
|
||||||
|
telegraf_agent_package_method: repo
|
||||||
telegraf_agent_package_state: present
|
telegraf_agent_package_state: present
|
||||||
telegraf_agent_hostname: "{{ ansible_fqdn }}"
|
telegraf_agent_hostname: "{{ ansible_fqdn }}"
|
||||||
telegraf_agent_interval: 10
|
telegraf_agent_interval: 10
|
||||||
|
@ -57,6 +57,10 @@ provisioner:
|
|||||||
lint:
|
lint:
|
||||||
name: ansible-lint
|
name: ansible-lint
|
||||||
inventory:
|
inventory:
|
||||||
|
host_vars:
|
||||||
|
telegraf-debian:
|
||||||
|
telegraf_agent_package: /tmp/telegraf_amd64.deb
|
||||||
|
telegraf_agent_package_method: online
|
||||||
group_vars:
|
group_vars:
|
||||||
all:
|
all:
|
||||||
telegraf_agent_package_state: latest
|
telegraf_agent_package_state: latest
|
||||||
|
@ -4,6 +4,6 @@ extends: default
|
|||||||
|
|
||||||
rules:
|
rules:
|
||||||
line-length:
|
line-length:
|
||||||
max: 140
|
max: 180
|
||||||
level: warning
|
level: warning
|
||||||
truthy: disable
|
truthy: disable
|
||||||
|
@ -6,6 +6,16 @@
|
|||||||
when:
|
when:
|
||||||
- telegraf_agent_package_state != "latest"
|
- 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"
|
- name: "Debian | Ensure the system can use the HTTPS transport for APT"
|
||||||
stat:
|
stat:
|
||||||
path: /usr/lib/apt/methods/https
|
path: /usr/lib/apt/methods/https
|
||||||
@ -29,6 +39,8 @@
|
|||||||
register: are_telegraf_dependencies_keys_installed
|
register: are_telegraf_dependencies_keys_installed
|
||||||
until: are_telegraf_dependencies_keys_installed is succeeded
|
until: are_telegraf_dependencies_keys_installed is succeeded
|
||||||
become: yes
|
become: yes
|
||||||
|
when:
|
||||||
|
- telegraf_agent_package_method == "repo"
|
||||||
|
|
||||||
- name: "Debian | Add Telegraf repository (using LSB)"
|
- name: "Debian | Add Telegraf repository (using LSB)"
|
||||||
apt_repository:
|
apt_repository:
|
||||||
@ -37,6 +49,7 @@
|
|||||||
state: present
|
state: present
|
||||||
become: yes
|
become: yes
|
||||||
when:
|
when:
|
||||||
|
- telegraf_agent_package_method == "repo"
|
||||||
- ansible_lsb is defined
|
- ansible_lsb is defined
|
||||||
- ansible_lsb.codename is defined
|
- ansible_lsb.codename is defined
|
||||||
|
|
||||||
@ -47,15 +60,34 @@
|
|||||||
state: present
|
state: present
|
||||||
become: yes
|
become: yes
|
||||||
when:
|
when:
|
||||||
|
- telegraf_agent_package_method == "repo"
|
||||||
- ansible_lsb is not defined or ansible_lsb.codename is not defined
|
- 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"
|
- name: "Debian | Install Telegraf package"
|
||||||
apt:
|
apt:
|
||||||
name: "{{ telegraf_agent_package }}"
|
name: "{{ telegraf_agent_package }}"
|
||||||
state: "{{ telegraf_agent_package_state }}"
|
state: "{{ telegraf_agent_package_state }}"
|
||||||
cache_valid_time: 900
|
|
||||||
force: True
|
|
||||||
register: is_telegraf_package_installed
|
register: is_telegraf_package_installed
|
||||||
until: is_telegraf_package_installed is succeeded
|
until: is_telegraf_package_installed is succeeded
|
||||||
notify: "Restart Telegraf"
|
notify: "Restart Telegraf"
|
||||||
become: yes
|
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"
|
||||||
|
@ -19,6 +19,15 @@
|
|||||||
baseurl: "{{ telegraf_yum_baseurl[ansible_distribution|lower] | default(telegraf_yum_baseurl['default']) }}"
|
baseurl: "{{ telegraf_yum_baseurl[ansible_distribution|lower] | default(telegraf_yum_baseurl['default']) }}"
|
||||||
gpgcheck: yes
|
gpgcheck: yes
|
||||||
gpgkey: https://repos.influxdata.com/influxdb.key
|
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"
|
- name: "RedHat | Install Telegraf package"
|
||||||
package:
|
package:
|
||||||
|
Reference in New Issue
Block a user