Add FreeBSD support

This commit is contained in:
Jannik Beyerstedt 2021-05-02 18:19:11 +02:00
parent 39045ed5a0
commit 22dd9bfb3d
6 changed files with 60 additions and 21 deletions

View file

@ -6,23 +6,6 @@
name: ssh name: ssh
state: restarted state: restarted
- name: Enable telegraf
service:
name: telegraf
enabled: yes
- name: Restart telegraf
service:
name: telegraf
state: restarted
- name: Enable and restart telegraf
become: yes
service:
name: telegraf
state: restarted
enabled: yes
- name: Enable caddy - name: Enable caddy
service: service:
name: caddy name: caddy

View file

@ -8,6 +8,7 @@
- "cronmails-{{ ansible_distribution }}.{{ ansible_distribution_release }}.yml" - "cronmails-{{ ansible_distribution }}.{{ ansible_distribution_release }}.yml"
- "cronmails-{{ ansible_distribution }}.yml" - "cronmails-{{ ansible_distribution }}.yml"
- "cronmails-{{ (override_os_family is defined) | ternary(override_os_family,ansible_os_family) }}.yml" - "cronmails-{{ (override_os_family is defined) | ternary(override_os_family,ansible_os_family) }}.yml"
ignore_errors: true
# Set cronjob env variables/ settings # Set cronjob env variables/ settings
- name: cronmails - Crontab set path - name: cronmails - Crontab set path

View file

@ -0,0 +1,31 @@
---
# Server/Telegraf: Install and Setup Telegraf Monitoring - FreeBSD Version
- name: telegraf - Install telegraf
become: yes
ansible.builtin.package:
name: telegraf
state: latest
# # Install SNMP utilities for telegraf monitoring
# - name: telegraf - Install SNMP utilities
# become: yes
# ansible.builtin.package:
# name: "{{ packages }}"
# state: present
# vars:
# packages:
# - snmp
# - snmp-mibs-downloader
# when: telegraf_ubnt_ns_ips is defined
- name: telegraf - Install SNMP utilities
become: yes
ansible.builtin.package:
name: "{{ packages }}"
state: present
vars:
packages:
- snmp
- snmp-mibs-downloader
when: telegraf_ubnt_ns_ips is defined

View file

@ -33,10 +33,23 @@
when: telegraf_ubnt_ns_ips is defined when: telegraf_ubnt_ns_ips is defined
# Configure # Configure
- name: telegraf - Copy telegraf config - name: telegraf - Copy telegraf config (Linux)
become: yes become: yes
template: template:
src: "{{ role_path }}/templates/telegraf.conf.j2" src: "{{ role_path }}/templates/telegraf.conf.j2"
dest: /etc/telegraf/telegraf.conf dest: /etc/telegraf/telegraf.conf
notify: when: (override_os_family is defined) | ternary(override_os_family,ansible_os_family) != "FreeBSD"
- Enable and restart telegraf
- name: telegraf - Copy telegraf config (FreeBSD)
become: yes
template:
src: "{{ role_path }}/templates/telegraf.conf.j2"
dest: /usr/local/etc/telegraf.conf
when: (override_os_family is defined) | ternary(override_os_family,ansible_os_family) == "FreeBSD"
- name: telegraf - Enable and restart telegraf
become: yes
service:
name: telegraf
state: restarted
enabled: yes

View file

@ -65,6 +65,8 @@ AcceptEnv LANG LC_*
# Log sftp level file access (read/write/etc.) that would not be easily logged otherwise. # Log sftp level file access (read/write/etc.) that would not be easily logged otherwise.
{% if ((override_os_family is defined) | ternary(override_os_family,ansible_os_family)) == 'Centos' %} {% if ((override_os_family is defined) | ternary(override_os_family,ansible_os_family)) == 'Centos' %}
Subsystem sftp /usr/libexec/openssh/sftp-server -f AUTHPRIV -l INFO Subsystem sftp /usr/libexec/openssh/sftp-server -f AUTHPRIV -l INFO
{% elif ((override_os_family is defined) | ternary(override_os_family,ansible_os_family)) == 'FreeBSD' %}
Subsystem sftp /usr/libexec/sftp-server
{% else %} {% else %}
Subsystem sftp /usr/lib/openssh/sftp-server -f AUTHPRIV -l INFO Subsystem sftp /usr/lib/openssh/sftp-server -f AUTHPRIV -l INFO
{% endif %} {% endif %}

View file

@ -32,7 +32,7 @@
# Read metrics about disk usage by mount point # Read metrics about disk usage by mount point
[[inputs.disk]] [[inputs.disk]]
# By default, telegraf gather stats for all mountpoints. # By default, telegraf gather stats for all mountpoints.
mount_points = ["/", "/mnt/volume-nbg1-1"] mount_points = ["/", "/mnt/volume-nbg1-1", "/zroot", "/zfspool/zfsstore"]
ignore_fs = ["tmpfs", "devtmpfs", "devfs", "overlay", "aufs", "squashfs"] ignore_fs = ["tmpfs", "devtmpfs", "devfs", "overlay", "aufs", "squashfs"]
fieldpass = ["total", "free", "used_percent"] fieldpass = ["total", "free", "used_percent"]
@ -83,3 +83,12 @@
data_type = "integer" data_type = "integer"
name_override = "cpu_temp" name_override = "cpu_temp"
{% endif %} {% endif %}
{% if ((override_os_family is defined) | ternary(override_os_family,ansible_os_family)) == 'FreeBSD' %}
# Read metrics of ZFS from arcstats, zfetchstats, vdev_cache_stats, and pools
[[inputs.zfs]]
## By default, telegraf gather all zfs stats
kstatMetrics = ["arcstats", "zfetchstats", "vdev_cache_stats"]
## By default, don't gather zpool stats
poolMetrics = true
{% endif %}