xoxys.telegraf/tasks/setup.yml

65 lines
1.7 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/influxdata-archive_compat.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
become: True
become_user: root