Robert Kaussow
e706bc53c5
All checks were successful
continuous-integration/drone/push Build is passing
72 lines
1.9 KiB
YAML
72 lines
1.9 KiB
YAML
---
|
|
- block:
|
|
- name: Add Telegraf repository
|
|
yum_repository:
|
|
name: influxdb
|
|
file: InfluxDB
|
|
description: InfluxDB Repository
|
|
baseurl: "https://repos.influxdata.com/rhel/{{ ansible_distribution_major_version }}/$basearch/stable"
|
|
gpgkey: https://repos.influxdata.com/influxdb.key
|
|
gpgcheck: yes
|
|
|
|
- name: Ensure dependencies are installed
|
|
package:
|
|
name: "{{ item }}"
|
|
state: present
|
|
loop: "{{ telegraf_packages_extra }}"
|
|
|
|
- name: Ensure Telegraf is installed
|
|
package:
|
|
name: "{{ item }}"
|
|
state: present
|
|
loop:
|
|
- telegraf
|
|
|
|
- name: Ensure Telegraf directories exist
|
|
file:
|
|
path: "{{ item }}"
|
|
state: directory
|
|
owner: telegraf
|
|
group: telegraf
|
|
mode: 0750
|
|
loop:
|
|
- /etc/telegraf/.cache/snowflake
|
|
|
|
- name: Copy custom Telegraf template files
|
|
template:
|
|
src: "{{ item }}"
|
|
dest: /etc/telegraf/telegraf.d/{{ item | basename | splitext | first }}
|
|
owner: telegraf
|
|
group: root
|
|
mode: 0640
|
|
with_fileglob: "{{ telegraf_template_files }}"
|
|
loop_control:
|
|
label: "{{ item | basename | splitext | first }}"
|
|
notify: __telegraf_reload
|
|
|
|
- name: Add docker group
|
|
user:
|
|
name: telegraf
|
|
groups: "{{ telegraf_docker_group_name }}"
|
|
append: True
|
|
notify: __telegraf_restart
|
|
when: telegraf_requires_docker_group
|
|
|
|
- name: Write config file
|
|
template:
|
|
src: etc/telegraf/telegraf/telegraf.conf.j2
|
|
dest: /etc/telegraf/telegraf.conf
|
|
owner: telegraf
|
|
group: root
|
|
mode: 0600
|
|
notify: __telegraf_reload
|
|
|
|
- name: Ensure Telegraf is up and running
|
|
service:
|
|
name: telegraf
|
|
daemon_reload: yes
|
|
enabled: yes
|
|
state: started
|
|
become: True
|
|
become_user: root
|