Hyperling
904dda6883
* Add openSUSE for initial testing. * Add package names for openSUSE Zypper. * Add commands for Zypper. Do apt clean after autoremove. * Add cronie to openSUSE. * Remove warn parameter for newer version of Ansible. * Commenting warn worked, removing it completely. * Add libvulkan1 since it's a dependency for GNOME. * Fix order of lynis and nmap. Thought I had already done this before? * Start adding package names for openSUSE. * Create the sshd_config file if it is not already present. * Fix OS in conditional. * Save the command for checking ansible variables. * Use openSUSE family since Tumbleweed and Leap are considered different distros. * Get rid of 2nd flathub repo, no longer use the dl. version.. * Add status update for openSUSE. * Reword sentence. * Add Brave Browser to openSUSE. * Script is running successfully now when Workstation is enabled. * Add status of openSUSE Leap. * Add space. * No longer use install-new-recommends.
174 lines
5.1 KiB
YAML
174 lines
5.1 KiB
YAML
---
|
|
# Application that populates InfluxDB with metric data.
|
|
# https://docs.influxdata.com/telegraf/v1.17/introduction/getting-started/
|
|
|
|
# Variables #
|
|
|
|
- name: General | Telegraf | Variables 1/4
|
|
set_fact:
|
|
telegraf_tar: telegraf-1.20.3_linux_amd64.tar.gz
|
|
telegraf_path: /usr/local/bin
|
|
telegraf_config_path: /usr/local/etc
|
|
telegraf_user: "{{ user_ansible.name }}"
|
|
telegraf_log: "{{ user_ansible.home }}/telegraf.log"
|
|
|
|
- name: General | Telegraf | Variables 2/4
|
|
set_fact:
|
|
telegraf_exec: "{{ telegraf_path }}/telegraf"
|
|
telegraf_config: "{{ telegraf_config_path }}/telegraf.conf"
|
|
|
|
- name: General | Telegraf | Variables 3/4
|
|
set_fact:
|
|
telegraf_cmd: "{{ telegraf_exec }} --config {{ telegraf_config }} >> {{ telegraf_log }} 2>&1"
|
|
|
|
- name: General | Telegraf | Variables 4/4
|
|
set_fact:
|
|
telegraf_watcher: "killall telegraf; {{ telegraf_cmd }}"
|
|
|
|
- name: General | Telegraf | Variables | Linux
|
|
set_fact:
|
|
telegraf_input_temp: "[[inputs.temp]]"
|
|
when: ansible_system == "Linux"
|
|
|
|
- name: General | Telegraf | Variables | FreeBSD
|
|
set_fact:
|
|
telegraf_input_temp: ""
|
|
when: ansible_system == "FreeBSD"
|
|
|
|
# Dependencies #
|
|
|
|
- name: General | Telegraf | Pre-Reqs
|
|
package:
|
|
name: wget
|
|
when: ansible_system == "Linux"
|
|
|
|
# Install #
|
|
|
|
- name: General | Telegraf | Linux | Install
|
|
shell: "{{ item }}"
|
|
args:
|
|
chdir: "{{ ansible_env.HOME }}/Downloads/"
|
|
loop:
|
|
- mkdir -p {{ telegraf_path }}
|
|
- mkdir -p {{ telegraf_config_path }}
|
|
- wget --no-check-certificate "https://dl.influxdata.com/telegraf/releases/{{ telegraf_tar }}"
|
|
- tar xvf {{ telegraf_tar }}
|
|
- mv {{ telegraf_tar }} ~/TRASH/
|
|
- mv telegraf*/usr/bin/telegraf {{ telegraf_exec }}
|
|
- rm -r telegraf*
|
|
when: ansible_system == "Linux"
|
|
|
|
- name: General | Telegraf | FreeBSD | Install 1/2
|
|
shell: /usr/sbin/pwd_mkdb -p /etc/master.passwd
|
|
when: ansible_system == "FreeBSD"
|
|
|
|
- name: General | Telegraf | FreeBSD | Install 2/2
|
|
package:
|
|
name: telegraf
|
|
when: ansible_system == "FreeBSD"
|
|
|
|
# Configuration #
|
|
|
|
- name: General | Telegraf | Config 1/2
|
|
shell: mv {{ telegraf_config }} ~/TRASH/
|
|
ignore_errors: yes
|
|
|
|
- name: General | Telegraf | Config 2/2
|
|
blockinfile:
|
|
path: "{{ telegraf_config }}"
|
|
block: |
|
|
[global_tags]
|
|
# dc = "us-east-1" # will tag all metrics with dc=us-east-1
|
|
# rack = "1a"
|
|
## Environment variables can be used as tags, and throughout the config file
|
|
# user = "$USER"
|
|
|
|
[agent]
|
|
interval = "{{ '300s' if battery else '5s' }}"
|
|
metric_batch_size = 1000
|
|
metric_buffer_limit = 10000
|
|
collection_jitter = "0s"
|
|
flush_interval = "30s"
|
|
flush_jitter = "10s"
|
|
precision = ""
|
|
# debug = false
|
|
# quiet = false
|
|
# logtarget = "file"
|
|
# logfile = ""
|
|
# logfile_rotation_interval = "0d"
|
|
# logfile_rotation_max_size = "0MB"
|
|
# logfile_rotation_max_archives = 5
|
|
hostname = ""
|
|
omit_hostname = false
|
|
|
|
[[outputs.influxdb]]
|
|
urls = ["http://influxdb.hyperling.com:8086"]
|
|
database = "main"
|
|
# database_tag = ""
|
|
# exclude_database_tag = false
|
|
# skip_database_creation = false
|
|
# retention_policy = ""
|
|
# retention_policy_tag = ""
|
|
# exclude_retention_policy_tag = false
|
|
# write_consistency = "any"
|
|
# timeout = "5s"
|
|
# username = "telegraf"
|
|
# password = "metricsmetricsmetricsmetrics"
|
|
# user_agent = "telegraf"
|
|
# udp_payload = "512B"
|
|
# tls_ca = "/etc/telegraf/ca.pem"
|
|
# tls_cert = "/etc/telegraf/cert.pem"
|
|
# tls_key = "/etc/telegraf/key.pem"
|
|
# insecure_skip_verify = false
|
|
# http_proxy = "http://corporate.proxy:3128"
|
|
# http_headers = {"X-Special-Header" = "Special-Value"}
|
|
# content_encoding = "gzip"
|
|
# influx_uint_support = false
|
|
|
|
[[inputs.cpu]]
|
|
percpu = false
|
|
totalcpu = true
|
|
collect_cpu_time = false
|
|
report_active = false
|
|
|
|
[[inputs.disk]]
|
|
# mount_points = ["/"]
|
|
ignore_fs = ["tmpfs", "devtmpfs", "devfs", "iso9660", "overlay", "aufs", "squashfs", "fdescfs", "procfs", "nullfs"]
|
|
|
|
[[inputs.diskio]]
|
|
# devices = ["sda", "sdb", "vd*"]
|
|
# skip_serial_number = false
|
|
# device_tags = ["ID_FS_TYPE", "ID_FS_USAGE"]
|
|
# name_templates = ["$ID_FS_LABEL","$DM_VG_NAME/$DM_LV_NAME"]
|
|
|
|
[[inputs.kernel]]
|
|
|
|
[[inputs.mem]]
|
|
|
|
[[inputs.processes]]
|
|
|
|
[[inputs.swap]]
|
|
|
|
[[inputs.system]]
|
|
# fielddrop = ["uptime_format"]
|
|
|
|
{{ telegraf_input_temp }}
|
|
|
|
marker: '# {mark} MANAGED BY ANSIBLE - telegraf.yml'
|
|
state: present
|
|
create: yes
|
|
|
|
# Run #
|
|
|
|
- name: General | Telegraf | Schedule
|
|
cron:
|
|
user: "{{ telegraf_user }}"
|
|
name: "{{ item.name }}"
|
|
job: "{{ item.command }}"
|
|
special_time: "{{ item.freq }}"
|
|
state: present
|
|
disabled: "{{ 'yes' if no_telem else 'no' }}"
|
|
loop:
|
|
- { "name": "Telegraf Reboot Job" , "freq": "reboot", "command": "{{ telegraf_cmd }}"}
|
|
- { "name": "Telegraf Keep-Alive Job", "freq": "hourly", "command": "{{ telegraf_watcher }}"}
|