ansible/roles/telegraf/tasks/main.yml

34 lines
878 B
YAML

#!/usr/bin/ansible-playbook
# vim:ft=ansible:
---
- name: Install and configure Telegraf
block:
- name: Add repo keys by URL
apt_key:
url: "{{ item }}"
loop:
- "https://repos.influxdata.com/influxdb.key"
- name: Add repos
apt_repository:
repo: "{{ item }}"
loop:
- "deb https://repos.influxdata.com/ubuntu {{ ansible_distribution_release }} stable"
- name: Install Telegraf
apt:
name:
- telegraf
- name: Copy configs
template:
src: "{{ item.src }}"
dest: "/etc/telegraf/telegraf.d/{{ item.dest }}"
mode: "0644"
loop:
- { src: "50-ansible.conf", dest: "50-ansible.conf" }
notify: restart telegraf
- name: Start and enable Telegraf
systemd:
name: telegraf
enabled: yes
state: started
become: yes