mirror of
https://gitlab.sectorq.eu/jaydee/ansible.git
synced 2025-01-23 12:38:11 +00:00
bitwarden
This commit is contained in:
parent
4d19b05594
commit
6e3ad23eec
@ -53,7 +53,7 @@ datacenter:
|
||||
ansible_ssh_pass: lacijaydee
|
||||
ansible_become_user: root
|
||||
ansible_become_password: lacijaydee
|
||||
proxmox:
|
||||
amd:
|
||||
hosts:
|
||||
192.168.77.4:
|
||||
vars:
|
||||
|
@ -34,7 +34,8 @@
|
||||
|
||||
- name: Install a .deb package from the internet
|
||||
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
|
||||
delay: 5
|
||||
when:
|
||||
@ -69,6 +70,7 @@
|
||||
- zabbix-agent2-plugin-*
|
||||
update_cache: yes
|
||||
when: inventory_hostname not in groups['nas']
|
||||
become: "{{ false if inventory_hostname in groups['nas'] else true }}"
|
||||
|
||||
|
||||
- name: Reconfigure zabbix agent Server
|
||||
|
@ -1,12 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from asyncio.log import logger
|
||||
import paho.mqtt
|
||||
import paho.mqtt.client as mqttClient
|
||||
if paho.mqtt.__version__[0] > '1':
|
||||
client = mqttClient.Client(mqttClient.CallbackAPIVersion.VERSION1)
|
||||
else:
|
||||
client = mqttClient.Client()
|
||||
import paho.mqtt.client as mqtt
|
||||
from getmac import get_mac_address
|
||||
import platform
|
||||
import socket
|
||||
@ -24,7 +19,7 @@ import random
|
||||
import requests
|
||||
#import psutil
|
||||
stats = {}
|
||||
VERSION = "1.0.26"
|
||||
VERSION = "1.0.27"
|
||||
curos = platform.system()
|
||||
host = platform.node().lower()
|
||||
print(host)
|
||||
@ -243,10 +238,7 @@ if _PUBLISH:
|
||||
else:
|
||||
print("Failed to connect, return code %d\n", rc)
|
||||
|
||||
if paho.mqtt.__version__[0] > '1':
|
||||
client = mqttClient.Client(mqttClient.CallbackAPIVersion.VERSION1)
|
||||
else:
|
||||
client = mqttClient.Client()
|
||||
client = mqtt.Client(client_id)
|
||||
client.username_pw_set(username, password)
|
||||
client.on_connect = on_connect
|
||||
client.connect(MQTT_HOST, MQTT_PORT)
|
||||
@ -876,8 +868,11 @@ def on_message(client, userdata, msg):
|
||||
else:
|
||||
if host == "nas" or host == "octopi":
|
||||
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"])
|
||||
elif host == "amd" or host == "ryzen":
|
||||
subprocess.Popen(["systemctl suspend"])
|
||||
|
||||
else:
|
||||
#subprocess.Popen(["/bin/systemctl", "suspend", "-i"])
|
||||
#subprocess.Popen(["sudo", "pm-suspend"])
|
||||
@ -932,10 +927,7 @@ def on_message(client, userdata, msg):
|
||||
except:
|
||||
print("not a json!")
|
||||
|
||||
if paho.mqtt.__version__[0] > '1':
|
||||
client = mqttClient.Client(mqttClient.CallbackAPIVersion.VERSION1)
|
||||
else:
|
||||
client = mqttClient.Client()
|
||||
client = mqtt.Client()
|
||||
payload = '{"status": "off"}'
|
||||
client.username_pw_set("jaydee", password="jaydee1")
|
||||
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
|
||||
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_fans())
|
||||
sences = psutil.sensors_temperatures()
|
||||
@ -1079,19 +1072,25 @@ else:
|
||||
cpu_data = sences["k10temp"][0]
|
||||
except:
|
||||
cpu_data = "None"
|
||||
writeLog(cpu_data)
|
||||
print("CPUDATA")
|
||||
print(cpu_data)
|
||||
print("#"*40)
|
||||
|
||||
|
||||
mb_data = sences["acpitz"][0]
|
||||
print("MBDATA")
|
||||
print(mb_data)
|
||||
print(mb_data.current)
|
||||
try:
|
||||
mb_data = sences["acpitz"][0]
|
||||
print(mb_data)
|
||||
print(mb_data.current)
|
||||
mb_data = mb_data.current
|
||||
except:
|
||||
mb_data = 0
|
||||
|
||||
|
||||
print("#"*40)
|
||||
|
||||
|
||||
try:
|
||||
print(psutil.sensors_fans())
|
||||
fan_data = psutil.sensors_fans()["asus"][0].current
|
||||
except:
|
||||
fan_data = "None"
|
||||
@ -1115,7 +1114,8 @@ else:
|
||||
#print(str(jn1["coretemp-isa-0000"]["Package id 0"]["temp1_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("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)
|
||||
elif host.lower() == "openmediavault" or host.lower() == "omv":
|
||||
#print(psutil.sensors_temperatures())
|
||||
|
@ -3,6 +3,14 @@
|
||||
ignore_unreachable: false
|
||||
become: True
|
||||
tasks:
|
||||
- name: Install bottle python package
|
||||
ansible.builtin.apt:
|
||||
name:
|
||||
- python3-pip
|
||||
- python3-pip
|
||||
- python3-pip
|
||||
- python3-pip
|
||||
- python3-pip
|
||||
- name: Upload service config
|
||||
ansible.builtin.copy:
|
||||
src: services/mqtt_srv.service
|
||||
@ -15,13 +23,13 @@
|
||||
mode: '755'
|
||||
owner: root
|
||||
- name: Install bottle python package
|
||||
ansible.builtin.pip:
|
||||
name:
|
||||
- paho-mqtt
|
||||
- getmac
|
||||
- ping3
|
||||
- psutil
|
||||
- autorandr
|
||||
ansible.builtin.shell: pip install {{ item }} --break-system-packages
|
||||
loop:
|
||||
- paho-mqtt
|
||||
- getmac
|
||||
- ping3
|
||||
- psutil
|
||||
- autorandr
|
||||
- name: Just force systemd to reread configs (2.4 and above)
|
||||
ansible.builtin.systemd:
|
||||
daemon_reload: true
|
||||
|
@ -27,8 +27,8 @@
|
||||
when: inventory_hostname in groups['raspberrypi5']
|
||||
- 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/*'
|
||||
ignore_errors: yes
|
||||
become: yes
|
||||
ignore_errors: true
|
||||
become: true
|
||||
register: result
|
||||
when: inventory_hostname in groups['raspberrypi5']
|
||||
|
||||
@ -40,7 +40,7 @@
|
||||
path: "{{ item }}"
|
||||
regexp: '^\s+set \$server\s+\"\w+.\w+.\w+.\w+\";'
|
||||
line: " set $server \"192.168.77.238\";"
|
||||
become: yes
|
||||
become: true
|
||||
with_items:
|
||||
- "{{ result.stdout_lines }}"
|
||||
when: inventory_hostname in groups['raspberrypi5']
|
||||
@ -67,8 +67,8 @@
|
||||
# seconds: 10
|
||||
- name: Update gitlab perms
|
||||
ansible.builtin.shell: 'docker exec -t gitlab update-permissions'
|
||||
ignore_errors: yes
|
||||
become: yes
|
||||
ignore_errors: true
|
||||
become: true
|
||||
register: result
|
||||
when: inventory_hostname in groups['raspberrypi5']
|
||||
# - name: Get relevant configs
|
||||
|
@ -1,7 +1,11 @@
|
||||
- hosts: omv
|
||||
- hosts: datacenter
|
||||
name: Enable WOL
|
||||
become: true
|
||||
tasks:
|
||||
- name: Install ethtool
|
||||
ansible.builtin.apt:
|
||||
name: ethtool
|
||||
state: present
|
||||
- name: Display all interfaces name
|
||||
debug:
|
||||
var: ansible_facts.interfaces
|
||||
@ -12,7 +16,7 @@
|
||||
when: 'item.startswith("en")'
|
||||
|
||||
- name: Creating config
|
||||
become: yes
|
||||
become: true
|
||||
ansible.builtin.copy:
|
||||
|
||||
dest: "/etc/systemd/system/wol.service"
|
||||
|
Loading…
x
Reference in New Issue
Block a user