Jannik Beyerstedt
a0ac0a67a7
Having the when condition of a task at the top instead of bottom is easiert to read. Also some spaces were another whitespace character on accident.
56 lines
1.9 KiB
YAML
56 lines
1.9 KiB
YAML
---
|
|
# Server/Telegraf: Install and Setup Telegraf Monitoring
|
|
|
|
# Install
|
|
- 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"
|
|
|
|
# Install SNMP MIBs
|
|
- name: telegraf - Install SNMP MIBs
|
|
when: telegraf_ubnt_ns_ips is defined
|
|
become: yes
|
|
block:
|
|
- name: SNMP - Download and install Ubiquiti MIB
|
|
ansible.builtin.copy:
|
|
src: "{{ role_path }}/files/UBNT-MIB.txt"
|
|
dest: /usr/share/snmp/mibs/UBNT-MIB
|
|
- name: SNMP - Download and install Ubiquiti MIB
|
|
ansible.builtin.copy:
|
|
src: "{{ role_path }}/files/UBNT-AirMAX-MIB.txt"
|
|
dest: /usr/share/snmp/mibs/UBNT-AirMAX-MIB
|
|
- name: SNMP - Download and install UniFi MIB
|
|
ansible.builtin.copy:
|
|
src: "{{ role_path }}/files/UBNT-UniFi-MIB.txt"
|
|
dest: /usr/share/snmp/mibs/UBNT-UniFi-MIB
|
|
- name: SNMP - Setup snmp.conf
|
|
ansible.builtin.lineinfile:
|
|
name: /etc/snmp/snmp.conf
|
|
line: mibs +ALL
|
|
create: yes
|
|
|
|
# Configure
|
|
- name: telegraf - Copy telegraf config (Linux)
|
|
when: (override_os_family is defined) | ternary(override_os_family,ansible_os_family) != "FreeBSD"
|
|
become: yes
|
|
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"
|
|
become: yes
|
|
ansible.builtin.template:
|
|
src: "{{ role_path }}/templates/telegraf.conf.j2"
|
|
dest: /usr/local/etc/telegraf.conf
|
|
|
|
- name: telegraf - Enable and restart telegraf
|
|
become: yes
|
|
ansible.builtin.service:
|
|
name: telegraf
|
|
state: restarted
|
|
enabled: yes
|