diff --git a/group_vars/all.yml b/group_vars/all.yml index 7d2dabb..e9cd5f8 100644 --- a/group_vars/all.yml +++ b/group_vars/all.yml @@ -282,13 +282,13 @@ homeassistant: nut_server: ansible_host: usbip ups: - liebert-ps1: + liebert-psi: driver: usbhid-ups vendorid: "10af" productid: "0001" nut_client: - ups: liebert-ps1 + ups: liebert-psi sched: # How many seconds we are allowed to run on battery - on_bat: 300 \ No newline at end of file + on_bat: 300 # 5 minutes \ No newline at end of file diff --git a/hosts b/hosts index 00ef7eb..6d83f97 100644 --- a/hosts +++ b/hosts @@ -19,10 +19,10 @@ all: router-0: ansible_host: 192.168.10.10 nut_client: - ups: liebert-ps1 + ups: liebert-psi sched: # We want to shutdown this server last - on_bat: 3600 + on_bat: 10800 server-0: ansible_host: 192.168.10.11 vfio_pci_ids: @@ -34,22 +34,15 @@ all: - '10de:13c2' # NVIDIA Corporation GM204 [GeForce GTX 970] - '10de:13f1' # VGA compatible controller [0300]: NVIDIA Corporation GM204GL [Quadro M4000] nut_client: - ups: liebert-ps1 + ups: liebert-psi sched: # We want to shutdown this server quick - on_bat: 10 + on_bat: 15 bastion: hosts: bastion: ansible_host: 192.168.20.10 users_enable_sudo: false - plex: - hosts: - # plex: - # ansible_host: 192.168.20.31 - # nfs_libraries: - # - 192.168.20.30:/mnt/pool0/media/Movies - # - 192.168.20.30:/mnt/pool0/media/Series minecraft-server: # hosts: # minecraft-server: @@ -104,6 +97,8 @@ all: hosts: ubiquiti: ansible_host: 192.168.10.2 + satisfactory: + ansible_host: 192.168.20.31 children: proxmox: bastion: diff --git a/roles/nut-client/templates/upsmon.conf b/roles/nut-client/templates/upsmon.conf index 65db913..8b55f55 100644 --- a/roles/nut-client/templates/upsmon.conf +++ b/roles/nut-client/templates/upsmon.conf @@ -1,5 +1,5 @@ # TODO: setup credentials -MONITOR {{ nut_client.ups }}@{{ hostvars[nut_server.ansible_host]['ansible_default_ipv4']['address'] }} 1 monuser admin secondary +MONITOR {{ nut_client.ups }}@{{ hostvars[nut_server.ansible_host]['ansible_default_ipv4']['address'] }} 1 monuser admin slave MINSUPPLIES 1 diff --git a/roles/nut-server/files/upsd.conf b/roles/nut-server/files/upsd.conf index 61c76fc..b08a5a0 100644 --- a/roles/nut-server/files/upsd.conf +++ b/roles/nut-server/files/upsd.conf @@ -1 +1,2 @@ +#MAXAGE 15 LISTEN 0.0.0.0 3493 diff --git a/roles/nut-server/files/upsd.users b/roles/nut-server/files/upsd.users index c2ccda4..e31c349 100644 --- a/roles/nut-server/files/upsd.users +++ b/roles/nut-server/files/upsd.users @@ -1,4 +1,4 @@ # TODO: setup credentials [monuser] password = admin - upsmon secondary + upsmon slave diff --git a/roles/nut-server/handlers/main.yml b/roles/nut-server/handlers/main.yml index 9f7821c..c9681ea 100644 --- a/roles/nut-server/handlers/main.yml +++ b/roles/nut-server/handlers/main.yml @@ -15,3 +15,7 @@ name: nut-monitor enabled: true state: restarted + +- name: Reload udev + ansible.builtin.command: + cmd: "udevadm control --reload" \ No newline at end of file diff --git a/roles/nut-server/tasks/main.yml b/roles/nut-server/tasks/main.yml index 4d1844a..9176806 100644 --- a/roles/nut-server/tasks/main.yml +++ b/roles/nut-server/tasks/main.yml @@ -50,3 +50,10 @@ - Restart nut-server - Restart nut-client - Restart nut-monitor + +- name: Configure NUT udev rules + template: + src: 62-nut-usbups.rules + dest: /etc/udev/rules.d/62-nut-usbups.rules + notify: + - Reload udev \ No newline at end of file diff --git a/roles/nut-server/templates/62-nut-usbups.rules b/roles/nut-server/templates/62-nut-usbups.rules new file mode 100644 index 0000000..8c760a3 --- /dev/null +++ b/roles/nut-server/templates/62-nut-usbups.rules @@ -0,0 +1,7 @@ +SUBSYSTEM!="usb", GOTO="nut-usbups_rules_end" + +{% for name, config in nut_server.ups.items() %} +ACTION=="add|change", SUBSYSTEM=="usb|usb_device", SUBSYSTEMS=="usb|usb_device", ATTR{idVendor}=="{{ config.vendorid }}", ATTR{idProduct}=="{{ config.productid }}", MODE="664", GROUP="nut", RUN+="/sbin/upsdrvctl stop; /sbin/upsdrvctl start" +{% endfor %} + +LABEL="nut-usbups_rules_end" \ No newline at end of file diff --git a/roles/nut-server/templates/ups.conf b/roles/nut-server/templates/ups.conf index 92187d4..2ed395a 100644 --- a/roles/nut-server/templates/ups.conf +++ b/roles/nut-server/templates/ups.conf @@ -1,4 +1,5 @@ maxretry = 3 +pollinterval = 2 {% for name, config in nut_server.ups.items() %} [{{ name }}] diff --git a/roles/nut-server/templates/upsmon.conf b/roles/nut-server/templates/upsmon.conf index 0735707..2979fb9 100644 --- a/roles/nut-server/templates/upsmon.conf +++ b/roles/nut-server/templates/upsmon.conf @@ -1,4 +1,4 @@ # TODO: setup credentials {% for name in nut_server.ups.keys() %} -MONITOR {{ name }}@localhost 1 monuser admin primary +MONITOR {{ name }}@localhost 1 monuser admin master {% endfor %}