[TIDY] Move to ansible_facts dict instead of injected variables

This commit is contained in:
Jannik Beyerstedt 2025-12-20 21:08:31 +01:00
parent d1c6d34a64
commit 1c734cefb1
15 changed files with 39 additions and 39 deletions

View file

@ -5,9 +5,9 @@
- name: Telegraf - Install telegraf
ansible.builtin.include_tasks: "{{ item }}"
with_first_found:
- "telegraf-{{ ansible_distribution }}.{{ ansible_distribution_release }}.yml"
- "telegraf-{{ ansible_distribution }}.yml"
- "telegraf-{{ (override_os_family is defined) | ternary(override_os_family, ansible_os_family) }}.yml"
- "telegraf-{{ ansible_facts['distribution'] }}.{{ ansible_facts['distribution_release'] }}.yml"
- "telegraf-{{ ansible_facts['distribution'] }}.yml"
- "telegraf-{{ (override_os_family is defined) | ternary(override_os_family, ansible_facts['os_family']) }}.yml"
# Install SNMP MIBs
- name: Telegraf - Install SNMP MIBs
@ -34,14 +34,14 @@
# Configure
- name: Telegraf - Copy telegraf config (Linux)
when: (override_os_family is defined) | ternary(override_os_family, ansible_os_family) != "FreeBSD"
when: (override_os_family is defined) | ternary(override_os_family, ansible_facts['os_family']) != "FreeBSD"
become: true
ansible.builtin.template:
src: "{{ role_path }}/templates/telegraf.conf.j2"
dest: /etc/telegraf/telegraf.conf
- name: Telegraf - Copy telegraf config (FreeBSD)
when: (override_os_family is defined) | ternary(override_os_family, ansible_os_family) == "FreeBSD"
when: (override_os_family is defined) | ternary(override_os_family, ansible_facts['os_family']) == "FreeBSD"
become: true
ansible.builtin.template:
src: "{{ role_path }}/templates/telegraf.conf.j2"