ansible/roles/telegraf/tasks/main.yaml
Louis Vallat 700396cc31
feat: adding telegraf to docker group if docker is installed
Signed-off-by: Louis Vallat <louis@louis-vallat.xyz>
2023-03-12 14:34:43 +01:00

50 lines
1.1 KiB
YAML

---
- 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: Gather the package facts
ansible.builtin.package_facts:
manager: auto
- name: Add telegraf to docker group
ansible.builtin.user:
name: telegraf
groups: docker
append: true
when: "'docker-ce' in ansible_facts.packages"
- 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