Fix merge issue

This commit is contained in:
Werner Dijkerman
2018-11-26 17:03:37 +01:00
9 changed files with 138 additions and 18 deletions

View File

@ -14,8 +14,20 @@ Design goals are to have a minimal memory footprint with a plugin system so that
## Requirements
### Operating systems
This role will work on the following operating systems:
No requirements. (Yes, an Influxdb server somewhere on the network will help though ;-) )
* Red Hat
* Debian
* Ubuntu
* Windows (Best effort)
So, you'll need one of those operating systems.. :-)
Please sent Pull Requests or suggestions when you want to use this role for other Operating systems.
### InfluxDB
You'll need an InfluxDB instance running somewhere on your network.
## Upgrade
### 0.7.0
@ -26,6 +38,8 @@ There was an issue:
## Role Variables
### Overall variables
The following parameters can be set for the Telegraf agent:
* `telegraf_agent_version`: The version of Telegraf to install. Default: `1.9.0`
@ -70,6 +84,18 @@ The config will be printed line by line into the configuration, so you could als
and it will be printed in the configuration file.
## Windows specific Variables
**NOTE**
_Supporting Windows is an best effort (I don't have the possibility to either test/verify changes on the various amount of available Windows instances). PR's specific to Windows will almost immediately be merged, unless some one is able to provide a Windows test mechanism via Travis for Pull Requests._
* `telegraf_win_install_dir`: The directory where Telegraf will be installed.
* `telegraf_win_logfile`: The location to the logfile of Telegraf.
* `telegraf_win_include`: The directory that will contain all plugin configuration.
## Extra information
There are two properties which are similar, but are used differently. Those are:
* `telegraf_plugins_default`

View File

@ -54,3 +54,11 @@ telegraf_plugins_extra_exclusive: False
# RedHat specific settings for convenience
telegraf_redhat_releasever: "$releasever"
telegraf_win_install_dir: 'C:\Telegraf'
telegraf_win_logfile: 'C:\\Telegraf\\telegraf.log'
telegraf_win_include: 'C:\Telegraf\telegraf_agent.d\'
telegraf_win_service_args:
- -service install
- -config {{ telegraf_win_install_dir }}\telegraf\telegraf.conf
- --config-directory {{ telegraf_win_include }}

View File

@ -7,3 +7,9 @@
state: restarted
enabled: yes
become: yes
- name: "Restart Windows Telegraf"
win_service:
name: Telegraf
start_mode: auto
state: restarted

View File

@ -18,6 +18,9 @@ galaxy_info:
- name: opensuse
versions:
- all
- name: Windows
versions:
- all
galaxy_tags:
- monitoring

View File

@ -72,20 +72,6 @@ provisioner:
- name_override = "percpu_usage"
- fielddrop = ["cpu_time*"]
telegraf_plugins_default:
- plugin: cpu
config:
- percpu = true
- plugin: disk
- plugin: io
- plugin: mem
- plugin: net
- plugin: system
- plugin: swap
- plugin: netstat
- plugin: processes
- plugin: kernel
scenario:
name: default
verifier:

View File

@ -0,0 +1,78 @@
---
- name: "Windows | Create directory structure"
win_file:
path: "{{ item }}"
state: directory
with_items:
- "{{ telegraf_win_install_dir }}"
- "{{ telegraf_win_include }}"
- name: "Windows | Check if file is already downloaded"
win_stat:
path: '{{ telegraf_win_install_dir }}\telegraf-{{ telegraf_agent_version }}_windows_amd64.zip'
register: file_info
- name: "Windows | Download Telegraf Agent Zip file"
win_get_url:
url: https://dl.influxdata.com/telegraf/releases/telegraf-{{ telegraf_agent_version }}_windows_amd64.zip
dest: '{{ telegraf_win_install_dir }}\telegraf-{{ telegraf_agent_version }}_windows_amd64.zip'
when:
- not file_info.stat.exists
- name: "Windows | Unzip file"
win_unzip:
src: '{{ telegraf_win_install_dir }}\telegraf-{{ telegraf_agent_version }}_windows_amd64.zip'
dest: "{{ telegraf_win_install_dir }}"
creates: '{{ telegraf_win_install_dir }}\telegraf\telegraf.exe'
- name: "Windows | Configure Telegraf"
win_template:
src: telegraf.conf.j2
dest: '{{ telegraf_win_install_dir }}\telegraf\telegraf.conf'
notify: "Restart Windows Telegraf"
- name: "Windows | Copy telegraf extra plugins"
win_template:
src: "telegraf-extra-plugin.conf.j2"
dest: "/etc/telegraf/telegraf.d/{{ item.key }}.conf"
with_dict: "{{ telegraf_plugins_extra }}"
loop_control:
label: "{{ item.key }}"
when:
- telegraf_plugins_extra is defined
- telegraf_plugins_extra is iterable
- item.value.state|default('present') != 'absent'
notify: "Restart Windows Telegraf"
- name: "Windows | Remove telegraf extra plugins"
win_file:
path: "/etc/telegraf/telegraf.d/{{ item.key }}.conf"
state: absent
with_dict: "{{ telegraf_plugins_extra }}"
loop_control:
label: "{{ item.key }}"
when:
- telegraf_plugins_extra is defined
- telegraf_plugins_extra is iterable
- item.value.state|default('present') == 'absent'
notify: "Restart Windows Telegraf"
- name: "Windows | Register Service"
win_command: '{{ telegraf_win_install_dir }}\telegraf\telegraf.exe {{ telegraf_win_service_args | join(" ") }}'
register: telegraf_windows_install
args:
creates: '{{ telegraf_win_install_dir }}\.installed'
- name: "Windows | Create done file so it won't register itself again"
win_file:
path: '{{ telegraf_win_install_dir }}\.installed'
state: touch
when:
- telegraf_windows_install is changed
- name: "Windows | Set service startup mode to auto and ensure it is started"
win_service:
name: Telegraf
start_mode: auto
state: started

View File

@ -3,11 +3,13 @@
- name: "Install on RedHat"
include_tasks: "RedHat.yml"
when: ansible_os_family == "RedHat"
when:
- ansible_os_family == "RedHat"
- name: "Install on Debian"
include_tasks: "Debian.yml"
when: ansible_os_family == "Debian"
when:
- ansible_os_family == "Debian"
tags:
- telegraf
- packages
@ -17,4 +19,11 @@
when: ansible_os_family == "Suse"
- name: "Configure telegraf"
include_tasks: "configure.yml"
include_tasks: "configure_linux.yml"
when:
- ansible_os_family != "Windows"
- name: "Install / Configure telegraf on Windows"
include_tasks: "configure_windows.yml"
when:
- ansible_os_family == "Windows"

View File

@ -28,7 +28,11 @@
quiet = {{ telegraf_agent_quiet | lower }}
{% endif %}
{% if telegraf_agent_version is version_compare('1.1', '>=') %}
{% if ansible_os_family == "Windows" %}
logfile = "{{ telegraf_win_logfile }}"
{% else %}
logfile = "{{ telegraf_agent_logfile }}"
{% endif %}
omit_hostname = {{ telegraf_agent_omit_hostname | lower }}
{% endif %}