xoxys.telegraf/tasks/setup.yml
2021-06-03 18:55:27 +02:00

62 lines
1.6 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: 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_restart
- 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_restart
- name: Ensure Telegraf is up and running
systemd:
name: telegraf
daemon_reload: yes
enabled: yes
state: started
become: True
become_user: root