2019-10-06 22:55:56 +02:00
|
|
|
---
|
|
|
|
|
# Server/Telegraf: Install and Setup Telegraf Monitoring
|
|
|
|
|
|
2020-03-08 16:41:55 +01:00
|
|
|
# Install
|
2023-04-28 23:25:21 +02:00
|
|
|
- name: Telegraf - Install telegraf
|
2021-08-28 16:50:37 +02:00
|
|
|
ansible.builtin.include_tasks: "{{ item }}"
|
2020-03-08 16:41:55 +01:00
|
|
|
with_first_found:
|
2025-12-20 21:08:31 +01:00
|
|
|
- "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"
|
2019-10-06 22:55:56 +02:00
|
|
|
|
2020-05-22 13:18:45 +02:00
|
|
|
# Install SNMP MIBs
|
2023-04-28 23:25:21 +02:00
|
|
|
- name: Telegraf - Install SNMP MIBs
|
2022-02-13 20:52:02 +01:00
|
|
|
when: telegraf_ubnt_ns_ips is defined
|
2023-04-28 23:25:21 +02:00
|
|
|
become: true
|
2020-05-22 13:18:45 +02:00
|
|
|
block:
|
|
|
|
|
- name: SNMP - Download and install Ubiquiti MIB
|
2021-08-28 16:50:37 +02:00
|
|
|
ansible.builtin.copy:
|
2020-05-22 13:18:45 +02:00
|
|
|
src: "{{ role_path }}/files/UBNT-MIB.txt"
|
|
|
|
|
dest: /usr/share/snmp/mibs/UBNT-MIB
|
|
|
|
|
- name: SNMP - Download and install Ubiquiti MIB
|
2021-08-28 16:50:37 +02:00
|
|
|
ansible.builtin.copy:
|
2020-05-22 13:18:45 +02:00
|
|
|
src: "{{ role_path }}/files/UBNT-AirMAX-MIB.txt"
|
|
|
|
|
dest: /usr/share/snmp/mibs/UBNT-AirMAX-MIB
|
|
|
|
|
- name: SNMP - Download and install UniFi MIB
|
2021-08-28 16:50:37 +02:00
|
|
|
ansible.builtin.copy:
|
2020-05-22 13:18:45 +02:00
|
|
|
src: "{{ role_path }}/files/UBNT-UniFi-MIB.txt"
|
|
|
|
|
dest: /usr/share/snmp/mibs/UBNT-UniFi-MIB
|
|
|
|
|
- name: SNMP - Setup snmp.conf
|
2021-08-28 16:50:37 +02:00
|
|
|
ansible.builtin.lineinfile:
|
2020-05-22 13:18:45 +02:00
|
|
|
name: /etc/snmp/snmp.conf
|
|
|
|
|
line: mibs +ALL
|
|
|
|
|
create: yes
|
|
|
|
|
|
2020-03-08 16:41:55 +01:00
|
|
|
# Configure
|
2023-04-28 23:25:21 +02:00
|
|
|
- name: Telegraf - Copy telegraf config (Linux)
|
2025-12-20 21:08:31 +01:00
|
|
|
when: (override_os_family is defined) | ternary(override_os_family, ansible_facts['os_family']) != "FreeBSD"
|
2023-04-28 23:25:21 +02:00
|
|
|
become: true
|
2021-08-28 16:50:37 +02:00
|
|
|
ansible.builtin.template:
|
2020-05-22 13:18:45 +02:00
|
|
|
src: "{{ role_path }}/templates/telegraf.conf.j2"
|
2019-10-06 22:55:56 +02:00
|
|
|
dest: /etc/telegraf/telegraf.conf
|
2021-05-02 18:19:11 +02:00
|
|
|
|
2023-04-28 23:25:21 +02:00
|
|
|
- name: Telegraf - Copy telegraf config (FreeBSD)
|
2025-12-20 21:08:31 +01:00
|
|
|
when: (override_os_family is defined) | ternary(override_os_family, ansible_facts['os_family']) == "FreeBSD"
|
2023-04-28 23:25:21 +02:00
|
|
|
become: true
|
2021-08-28 16:50:37 +02:00
|
|
|
ansible.builtin.template:
|
2021-05-02 18:19:11 +02:00
|
|
|
src: "{{ role_path }}/templates/telegraf.conf.j2"
|
|
|
|
|
dest: /usr/local/etc/telegraf.conf
|
|
|
|
|
|
2023-04-28 23:25:21 +02:00
|
|
|
- name: Telegraf - Enable and restart telegraf
|
|
|
|
|
become: true
|
2021-08-28 16:50:37 +02:00
|
|
|
ansible.builtin.service:
|
2021-05-02 18:19:11 +02:00
|
|
|
name: telegraf
|
|
|
|
|
state: restarted
|
2023-04-28 23:25:21 +02:00
|
|
|
enabled: true
|