mirror of
https://github.com/wickedyoda/public-setupfiles.git
synced 2026-11-16 13:31:56 -06:00
playbooks
This commit is contained in:
1 parent
69802266ae
commit
ef1efe26b2
36 files changed
+1770
No files matched your search
@@ -0,0 +1,59 @@
|
||||
---
|
||||
- name: Fix Linux Telegraf configs
|
||||
hosts: linux_servers
|
||||
gather_facts: false
|
||||
vars:
|
||||
influxdb_url: "http://docker2.tail99133.ts.net:8086"
|
||||
influxdb_org: "homelab"
|
||||
influxdb_bucket: "telegraf"
|
||||
telegraf_conf_path: /etc/telegraf/telegraf.conf
|
||||
secret_path: /etc/telegraf/secrets/token
|
||||
nas_token_path: /mnt/nas/public/Hermes_Data/secrets/influxdb/token
|
||||
|
||||
tasks:
|
||||
- name: Read InfluxDB token from NAS
|
||||
local_action:
|
||||
module: slurp
|
||||
src: "{{ nas_token_path }}"
|
||||
register: nas_token
|
||||
run_once: true
|
||||
|
||||
- name: Set InfluxDB token fact
|
||||
set_fact:
|
||||
influxdb_token: "{{ nas_token.content | b64decode }}"
|
||||
|
||||
- name: Deploy InfluxDB token to secret path
|
||||
copy:
|
||||
content: "{{ influxdb_token }}"
|
||||
dest: "{{ secret_path }}"
|
||||
mode: "0600"
|
||||
owner: root
|
||||
group: root
|
||||
|
||||
- name: Update telegraf.conf URL
|
||||
replace:
|
||||
path: "{{ telegraf_conf_path }}"
|
||||
regexp: 'urls = \[.*\]'
|
||||
replace: 'urls = ["{{ influxdb_url }}"]'
|
||||
|
||||
- name: Update telegraf.conf token reference
|
||||
replace:
|
||||
path: "{{ telegraf_conf_path }}"
|
||||
regexp: 'token = ".*"'
|
||||
replace: 'token = "@{{ secret_path }}"'
|
||||
|
||||
- name: Update telegraf.conf org and bucket
|
||||
replace:
|
||||
path: "{{ telegraf_conf_path }}"
|
||||
regexp: "{{ item.regexp }}"
|
||||
replace: "{{ item.replace }}"
|
||||
loop:
|
||||
- regexp: "organization = \".*\""
|
||||
replace: "organization = \"{{ influxdb_org }}\""
|
||||
- regexp: "bucket = \".*\""
|
||||
replace: "bucket = \"{{ influxdb_bucket }}\""
|
||||
|
||||
- name: Restart Telegraf to apply changes
|
||||
service:
|
||||
name: telegraf
|
||||
state: restarted
|
||||
Reference in new issue
Block a user