From 20fd717e0bd96c085caf5d860398711c0886e394 Mon Sep 17 00:00:00 2001 From: Louis Vallat Date: Sun, 12 Mar 2023 14:10:52 +0100 Subject: [PATCH] feat: added telegraf role to setup telegraf Signed-off-by: Louis Vallat --- roles/telegraf/tasks/main.yaml | 38 ++++++++++++++++++++++++++++++++++ telegraf.yaml | 5 +++++ 2 files changed, 43 insertions(+) create mode 100644 roles/telegraf/tasks/main.yaml create mode 100644 telegraf.yaml diff --git a/roles/telegraf/tasks/main.yaml b/roles/telegraf/tasks/main.yaml new file mode 100644 index 0000000..18624c5 --- /dev/null +++ b/roles/telegraf/tasks/main.yaml @@ -0,0 +1,38 @@ +--- +- name: Install required system packages + ansible.builtin.apt: + pkg: + - apt-transport-https + - ca-certificates + - gnupg + - curl + state: latest + update_cache: true + +- name: Add Influxdata GPG apt key + ansible.builtin.apt_key: + url: "https://repos.influxdata.com/influxdata-archive.key" + state: present + +- name: Add Influxdata repository + ansible.builtin.apt_repository: + repo: deb https://repos.influxdata.com/{{ ansible_distribution | lower }} {{ ansible_distribution_release }} stable + state: present + filename: "telegraf" + +- name: Install telegraf package + ansible.builtin.apt: + pkg: + - telegraf + state: latest + update_cache: true + +- name: Enable telegraf service + ansible.builtin.service: + name: telegraf + enabled: true + +- name: Stop telegraf service (configure it before starting) + ansible.builtin.service: + name: telegraf + state: stopped diff --git a/telegraf.yaml b/telegraf.yaml new file mode 100644 index 0000000..4ac73ac --- /dev/null +++ b/telegraf.yaml @@ -0,0 +1,5 @@ +--- +- name: "Install telegraf on debian." + hosts: telegraf + roles: + - telegraf