mirror of
https://gitlab.sectorq.eu/jaydee/ansible.git
synced 2025-01-23 20:39:26 +00:00
bitwarden
This commit is contained in:
parent
4d19b05594
commit
6e3ad23eec
@ -53,7 +53,7 @@ datacenter:
|
|||||||
ansible_ssh_pass: lacijaydee
|
ansible_ssh_pass: lacijaydee
|
||||||
ansible_become_user: root
|
ansible_become_user: root
|
||||||
ansible_become_password: lacijaydee
|
ansible_become_password: lacijaydee
|
||||||
proxmox:
|
amd:
|
||||||
hosts:
|
hosts:
|
||||||
192.168.77.4:
|
192.168.77.4:
|
||||||
vars:
|
vars:
|
||||||
|
@ -34,7 +34,8 @@
|
|||||||
|
|
||||||
- name: Install a .deb package from the internet
|
- name: Install a .deb package from the internet
|
||||||
ansible.builtin.apt:
|
ansible.builtin.apt:
|
||||||
deb: https://repo.zabbix.com/zabbix/6.4/raspbian/pool/main/z/zabbix-release/zabbix-release_6.4-1+debian11_all.deb
|
#deb: https://repo.zabbix.com/zabbix/6.4/raspbian/pool/main/z/zabbix-release/zabbix-release_6.4-1+debian11_all.deb
|
||||||
|
deb: https://repo.zabbix.com/zabbix/7.0/raspbian/pool/main/z/zabbix-release/zabbix-release_7.0-1+debian11_all.deb
|
||||||
retries: 5
|
retries: 5
|
||||||
delay: 5
|
delay: 5
|
||||||
when:
|
when:
|
||||||
@ -69,6 +70,7 @@
|
|||||||
- zabbix-agent2-plugin-*
|
- zabbix-agent2-plugin-*
|
||||||
update_cache: yes
|
update_cache: yes
|
||||||
when: inventory_hostname not in groups['nas']
|
when: inventory_hostname not in groups['nas']
|
||||||
|
become: "{{ false if inventory_hostname in groups['nas'] else true }}"
|
||||||
|
|
||||||
|
|
||||||
- name: Reconfigure zabbix agent Server
|
- name: Reconfigure zabbix agent Server
|
||||||
|
@ -1,12 +1,7 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
from asyncio.log import logger
|
from asyncio.log import logger
|
||||||
import paho.mqtt
|
import paho.mqtt.client as mqtt
|
||||||
import paho.mqtt.client as mqttClient
|
|
||||||
if paho.mqtt.__version__[0] > '1':
|
|
||||||
client = mqttClient.Client(mqttClient.CallbackAPIVersion.VERSION1)
|
|
||||||
else:
|
|
||||||
client = mqttClient.Client()
|
|
||||||
from getmac import get_mac_address
|
from getmac import get_mac_address
|
||||||
import platform
|
import platform
|
||||||
import socket
|
import socket
|
||||||
@ -24,7 +19,7 @@ import random
|
|||||||
import requests
|
import requests
|
||||||
#import psutil
|
#import psutil
|
||||||
stats = {}
|
stats = {}
|
||||||
VERSION = "1.0.26"
|
VERSION = "1.0.27"
|
||||||
curos = platform.system()
|
curos = platform.system()
|
||||||
host = platform.node().lower()
|
host = platform.node().lower()
|
||||||
print(host)
|
print(host)
|
||||||
@ -243,10 +238,7 @@ if _PUBLISH:
|
|||||||
else:
|
else:
|
||||||
print("Failed to connect, return code %d\n", rc)
|
print("Failed to connect, return code %d\n", rc)
|
||||||
|
|
||||||
if paho.mqtt.__version__[0] > '1':
|
client = mqtt.Client(client_id)
|
||||||
client = mqttClient.Client(mqttClient.CallbackAPIVersion.VERSION1)
|
|
||||||
else:
|
|
||||||
client = mqttClient.Client()
|
|
||||||
client.username_pw_set(username, password)
|
client.username_pw_set(username, password)
|
||||||
client.on_connect = on_connect
|
client.on_connect = on_connect
|
||||||
client.connect(MQTT_HOST, MQTT_PORT)
|
client.connect(MQTT_HOST, MQTT_PORT)
|
||||||
@ -876,8 +868,11 @@ def on_message(client, userdata, msg):
|
|||||||
else:
|
else:
|
||||||
if host == "nas" or host == "octopi":
|
if host == "nas" or host == "octopi":
|
||||||
subprocess.Popen(["/sbin/poweroff"])
|
subprocess.Popen(["/sbin/poweroff"])
|
||||||
elif host == "openmediavault" or host == "omv":
|
elif host == "openmediavault" or host == "omv" or host == "amd" or host == "ryzen":
|
||||||
subprocess.Popen(["poweroff"])
|
subprocess.Popen(["poweroff"])
|
||||||
|
elif host == "amd" or host == "ryzen":
|
||||||
|
subprocess.Popen(["systemctl suspend"])
|
||||||
|
|
||||||
else:
|
else:
|
||||||
#subprocess.Popen(["/bin/systemctl", "suspend", "-i"])
|
#subprocess.Popen(["/bin/systemctl", "suspend", "-i"])
|
||||||
#subprocess.Popen(["sudo", "pm-suspend"])
|
#subprocess.Popen(["sudo", "pm-suspend"])
|
||||||
@ -932,10 +927,7 @@ def on_message(client, userdata, msg):
|
|||||||
except:
|
except:
|
||||||
print("not a json!")
|
print("not a json!")
|
||||||
|
|
||||||
if paho.mqtt.__version__[0] > '1':
|
client = mqtt.Client()
|
||||||
client = mqttClient.Client(mqttClient.CallbackAPIVersion.VERSION1)
|
|
||||||
else:
|
|
||||||
client = mqttClient.Client()
|
|
||||||
payload = '{"status": "off"}'
|
payload = '{"status": "off"}'
|
||||||
client.username_pw_set("jaydee", password="jaydee1")
|
client.username_pw_set("jaydee", password="jaydee1")
|
||||||
client.will_set("home-assistant/" + host.lower() + "/hwstats", payload=payload, qos=0, retain=True)
|
client.will_set("home-assistant/" + host.lower() + "/hwstats", payload=payload, qos=0, retain=True)
|
||||||
@ -1065,7 +1057,8 @@ else:
|
|||||||
NEXT_CHECK = int(time.time()) + 20
|
NEXT_CHECK = int(time.time()) + 20
|
||||||
writeLog("Blalala : Next : " + str(NEXT_CHECK))
|
writeLog("Blalala : Next : " + str(NEXT_CHECK))
|
||||||
|
|
||||||
if host.lower() == "asus" or host.lower() == "morefine":
|
if host.lower() == "asus" or host.lower() == "morefine" or host.lower() == "ryzen":
|
||||||
|
writeLog("Blalala : AAA")
|
||||||
print(psutil.sensors_temperatures())
|
print(psutil.sensors_temperatures())
|
||||||
#print(psutil.sensors_fans())
|
#print(psutil.sensors_fans())
|
||||||
sences = psutil.sensors_temperatures()
|
sences = psutil.sensors_temperatures()
|
||||||
@ -1079,19 +1072,25 @@ else:
|
|||||||
cpu_data = sences["k10temp"][0]
|
cpu_data = sences["k10temp"][0]
|
||||||
except:
|
except:
|
||||||
cpu_data = "None"
|
cpu_data = "None"
|
||||||
|
writeLog(cpu_data)
|
||||||
print("CPUDATA")
|
print("CPUDATA")
|
||||||
print(cpu_data)
|
print(cpu_data)
|
||||||
print("#"*40)
|
print("#"*40)
|
||||||
|
|
||||||
|
|
||||||
mb_data = sences["acpitz"][0]
|
|
||||||
print("MBDATA")
|
print("MBDATA")
|
||||||
print(mb_data)
|
try:
|
||||||
print(mb_data.current)
|
mb_data = sences["acpitz"][0]
|
||||||
|
print(mb_data)
|
||||||
|
print(mb_data.current)
|
||||||
|
mb_data = mb_data.current
|
||||||
|
except:
|
||||||
|
mb_data = 0
|
||||||
|
|
||||||
|
|
||||||
print("#"*40)
|
print("#"*40)
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
print(psutil.sensors_fans())
|
||||||
fan_data = psutil.sensors_fans()["asus"][0].current
|
fan_data = psutil.sensors_fans()["asus"][0].current
|
||||||
except:
|
except:
|
||||||
fan_data = "None"
|
fan_data = "None"
|
||||||
@ -1115,7 +1114,8 @@ else:
|
|||||||
#print(str(jn1["coretemp-isa-0000"]["Package id 0"]["temp1_input"]))
|
#print(str(jn1["coretemp-isa-0000"]["Package id 0"]["temp1_input"]))
|
||||||
#print(str(jn1["asus-isa-0000"]["cpu_fan"]["fan1_input"]))
|
#print(str(jn1["asus-isa-0000"]["cpu_fan"]["fan1_input"]))
|
||||||
#client.publish("sectorq/monitor/" + host.lower(), payload="{\"mb_temp\":0,\"mem_usage\":0,\"cpu_temp\":0,\"cpu_usage\":0,\"gpu_temp\":0,\"gpu_usage\":0}", qos=0, retain=False)
|
#client.publish("sectorq/monitor/" + host.lower(), payload="{\"mb_temp\":0,\"mem_usage\":0,\"cpu_temp\":0,\"cpu_usage\":0,\"gpu_temp\":0,\"gpu_usage\":0}", qos=0, retain=False)
|
||||||
client.publish("home-assistant/" + host + "/hwstats", payload='{"status":"on", "version":"' + VERSION + '","TCPU":"NA", "MB_TEMP":' + str(mb_data.current) + ', "MEM_UTIL":' + str(mem_data.percent) + ', "CPU_TEMP":' + str(cpu_data.current) + ', "GPU_TEMP":0, "GPU_UTIL":0, "FAN_CPU":"' + str(fan_data) + '", "VMEM_UTIL":' + str(swap_data.percent) + ', "CPU_UTIL":' + str(cpu_usage) + '}', qos=0, retain=False)
|
writeLog('{"status":"on", "version":"' + VERSION + '","TCPU":"NA", "MB_TEMP":' + str(mb_data) + ', "MEM_UTIL":' + str(mem_data.percent) + ', "CPU_TEMP":' + str(cpu_data.current) + ', "GPU_TEMP":0, "GPU_UTIL":0, "FAN_CPU":"' + str(fan_data) + '", "VMEM_UTIL":' + str(swap_data.percent) + ', "CPU_UTIL":' + str(cpu_usage) + '}')
|
||||||
|
client.publish("home-assistant/" + host + "/hwstats", payload='{"status":"on", "version":"' + VERSION + '","TCPU":"NA", "MB_TEMP":' + str(mb_data) + ', "MEM_UTIL":' + str(mem_data.percent) + ', "CPU_TEMP":' + str(cpu_data.current) + ', "GPU_TEMP":0, "GPU_UTIL":0, "FAN_CPU":"' + str(fan_data) + '", "VMEM_UTIL":' + str(swap_data.percent) + ', "CPU_UTIL":' + str(cpu_usage) + '}', qos=0, retain=False)
|
||||||
client.publish("sectorq/systems/" + host.lower() + "/stat", payload="on", qos=0, retain=True)
|
client.publish("sectorq/systems/" + host.lower() + "/stat", payload="on", qos=0, retain=True)
|
||||||
elif host.lower() == "openmediavault" or host.lower() == "omv":
|
elif host.lower() == "openmediavault" or host.lower() == "omv":
|
||||||
#print(psutil.sensors_temperatures())
|
#print(psutil.sensors_temperatures())
|
||||||
|
@ -3,6 +3,14 @@
|
|||||||
ignore_unreachable: false
|
ignore_unreachable: false
|
||||||
become: True
|
become: True
|
||||||
tasks:
|
tasks:
|
||||||
|
- name: Install bottle python package
|
||||||
|
ansible.builtin.apt:
|
||||||
|
name:
|
||||||
|
- python3-pip
|
||||||
|
- python3-pip
|
||||||
|
- python3-pip
|
||||||
|
- python3-pip
|
||||||
|
- python3-pip
|
||||||
- name: Upload service config
|
- name: Upload service config
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
src: services/mqtt_srv.service
|
src: services/mqtt_srv.service
|
||||||
@ -15,13 +23,13 @@
|
|||||||
mode: '755'
|
mode: '755'
|
||||||
owner: root
|
owner: root
|
||||||
- name: Install bottle python package
|
- name: Install bottle python package
|
||||||
ansible.builtin.pip:
|
ansible.builtin.shell: pip install {{ item }} --break-system-packages
|
||||||
name:
|
loop:
|
||||||
- paho-mqtt
|
- paho-mqtt
|
||||||
- getmac
|
- getmac
|
||||||
- ping3
|
- ping3
|
||||||
- psutil
|
- psutil
|
||||||
- autorandr
|
- autorandr
|
||||||
- name: Just force systemd to reread configs (2.4 and above)
|
- name: Just force systemd to reread configs (2.4 and above)
|
||||||
ansible.builtin.systemd:
|
ansible.builtin.systemd:
|
||||||
daemon_reload: true
|
daemon_reload: true
|
||||||
|
@ -27,8 +27,8 @@
|
|||||||
when: inventory_hostname in groups['raspberrypi5']
|
when: inventory_hostname in groups['raspberrypi5']
|
||||||
- name: Get relevant configs
|
- name: Get relevant configs
|
||||||
ansible.builtin.shell: 'egrep -l "# kestra.sectorq.eu|# auth.sectorq.eu|# ha.sectorq.eu|# pw.sectorq.eu|# semaphore.sectorq.eu|# sectorq.eu|# gitlab.sectorq.eu|# ha.sectorq.eu" /share/docker_data/nginx/data/nginx/proxy_host/*'
|
ansible.builtin.shell: 'egrep -l "# kestra.sectorq.eu|# auth.sectorq.eu|# ha.sectorq.eu|# pw.sectorq.eu|# semaphore.sectorq.eu|# sectorq.eu|# gitlab.sectorq.eu|# ha.sectorq.eu" /share/docker_data/nginx/data/nginx/proxy_host/*'
|
||||||
ignore_errors: yes
|
ignore_errors: true
|
||||||
become: yes
|
become: true
|
||||||
register: result
|
register: result
|
||||||
when: inventory_hostname in groups['raspberrypi5']
|
when: inventory_hostname in groups['raspberrypi5']
|
||||||
|
|
||||||
@ -40,7 +40,7 @@
|
|||||||
path: "{{ item }}"
|
path: "{{ item }}"
|
||||||
regexp: '^\s+set \$server\s+\"\w+.\w+.\w+.\w+\";'
|
regexp: '^\s+set \$server\s+\"\w+.\w+.\w+.\w+\";'
|
||||||
line: " set $server \"192.168.77.238\";"
|
line: " set $server \"192.168.77.238\";"
|
||||||
become: yes
|
become: true
|
||||||
with_items:
|
with_items:
|
||||||
- "{{ result.stdout_lines }}"
|
- "{{ result.stdout_lines }}"
|
||||||
when: inventory_hostname in groups['raspberrypi5']
|
when: inventory_hostname in groups['raspberrypi5']
|
||||||
@ -67,8 +67,8 @@
|
|||||||
# seconds: 10
|
# seconds: 10
|
||||||
- name: Update gitlab perms
|
- name: Update gitlab perms
|
||||||
ansible.builtin.shell: 'docker exec -t gitlab update-permissions'
|
ansible.builtin.shell: 'docker exec -t gitlab update-permissions'
|
||||||
ignore_errors: yes
|
ignore_errors: true
|
||||||
become: yes
|
become: true
|
||||||
register: result
|
register: result
|
||||||
when: inventory_hostname in groups['raspberrypi5']
|
when: inventory_hostname in groups['raspberrypi5']
|
||||||
# - name: Get relevant configs
|
# - name: Get relevant configs
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
- hosts: omv
|
- hosts: datacenter
|
||||||
name: Enable WOL
|
name: Enable WOL
|
||||||
become: true
|
become: true
|
||||||
tasks:
|
tasks:
|
||||||
|
- name: Install ethtool
|
||||||
|
ansible.builtin.apt:
|
||||||
|
name: ethtool
|
||||||
|
state: present
|
||||||
- name: Display all interfaces name
|
- name: Display all interfaces name
|
||||||
debug:
|
debug:
|
||||||
var: ansible_facts.interfaces
|
var: ansible_facts.interfaces
|
||||||
@ -12,7 +16,7 @@
|
|||||||
when: 'item.startswith("en")'
|
when: 'item.startswith("en")'
|
||||||
|
|
||||||
- name: Creating config
|
- name: Creating config
|
||||||
become: yes
|
become: true
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
|
|
||||||
dest: "/etc/systemd/system/wol.service"
|
dest: "/etc/systemd/system/wol.service"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user