Allow to install the latest version

This commit is contained in:
Werner Dijkerman
2018-11-22 20:52:17 +01:00
parent 126dbb8b22
commit 139943a832
4 changed files with 21 additions and 7 deletions

View File

@ -24,13 +24,13 @@ There was an issue:
If I configure a telegraf_plugins_extra, run ansible, delete the plugin and run ansible again, the plugin stays on the machine.
## Role Variables
The following parameters can be set for the Telegraf agent:
* `telegraf_agent_version`: The version of Telegraf to install. Default: `1.0.0`
* `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_package_state`: If the package should be `present` or `latest`. When set to `latest`, `telegraf_agent_version` will be ignored. Default: `present`
* `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

View File

@ -3,6 +3,8 @@
telegraf_agent_version: 1.9.0
telegraf_agent_version_patch: 1
telegraf_agent_package: telegraf
telegraf_agent_package_state: latest
telegraf_agent_hostname: "{{ ansible_fqdn }}"
telegraf_agent_interval: 10
telegraf_agent_debug: False

View File

@ -1,5 +1,11 @@
---
- name: "Set name if state == latest"
set_fact:
telegraf_agent_package: telegraf={{ telegraf_agent_version }}-{{ telegraf_agent_version_patch }}
when:
- telegraf_agent_package_state != "latest"
- name: Ensure the system can use the HTTPS transport for APT.
stat:
path: /usr/lib/apt/methods/https
@ -41,8 +47,8 @@
- name: "Install telegraf package | Debian"
apt:
name: telegraf={{ telegraf_agent_version }}-{{ telegraf_agent_version_patch }}
state: present
name: "{{ telegraf_agent_package }}"
state: "{{ telegraf_agent_package_state }}"
force: True
notify: "Restart Telegraf"
become: yes

View File

@ -1,6 +1,12 @@
---
# description: RedHat specific installation
- name: "Set name if state == latest"
set_fact:
telegraf_agent_package: telegraf-{{ telegraf_agent_version }}
when:
- telegraf_agent_package_state != "latest"
- name: "Add yum repository | RedHat"
yum_repository:
name: influxdb
@ -11,6 +17,6 @@
- name: "Install telegraf package | RedHat"
yum:
name: telegraf-{{ telegraf_agent_version }}
state: present
name: "{{ telegraf_agent_package }}"
state: "{{ telegraf_agent_package_state }}"
notify: "Restart Telegraf"