xoxys.telegraf/tasks/setup.yml

62 lines
1.6 KiB
YAML
Raw Normal View History

2021-06-03 16:55:27 +00:00
---
- 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 }}"
2021-06-05 15:21:20 +00:00
notify: __telegraf_reload
2021-06-03 16:55:27 +00:00
- 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
2021-06-05 15:21:20 +00:00
notify: __telegraf_reload
2021-06-03 16:55:27 +00:00
- name: Ensure Telegraf is up and running
service:
2021-06-03 16:55:27 +00:00
name: telegraf
daemon_reload: yes
enabled: yes
state: started
become: True
become_user: root