From 1ca0272031dd64b8916da1341a7f1f795c70e4c2 Mon Sep 17 00:00:00 2001 From: DarkFeather Date: Thu, 21 Dec 2023 12:58:32 -0600 Subject: [PATCH] Adding ucode & UPS definitions to IAC --- examples/msn0.yml | 13 +++++-------- playbooks/deploy.yml | 2 +- roles/Sharingan/files/monit/checks/cyberpower | 2 ++ roles/Sharingan/files/monit/hostdefs/Node2 | 1 + .../Sharingan/files/monit/scripts/check-cyberpower | 6 ++++++ roles/hardware/tasks/amd.yml | 13 +++++++++++++ roles/hardware/tasks/cyberpower.yml | 14 ++++++++++++++ roles/hardware/tasks/intel.yml | 13 +++++++++++++ roles/hardware/tasks/main.yml | 12 +++++++++++- 9 files changed, 66 insertions(+), 10 deletions(-) create mode 100644 roles/Sharingan/files/monit/checks/cyberpower create mode 100755 roles/Sharingan/files/monit/scripts/check-cyberpower create mode 100644 roles/hardware/tasks/amd.yml create mode 100644 roles/hardware/tasks/cyberpower.yml create mode 100644 roles/hardware/tasks/intel.yml diff --git a/examples/msn0.yml b/examples/msn0.yml index 9ef93dc..28bb55f 100644 --- a/examples/msn0.yml +++ b/examples/msn0.yml @@ -44,21 +44,18 @@ all: ip: 10.0.1.2 mac: B8:27:EB:B6:AA:0C static: true - Node0: - ipinterface: enp1s0f0 - ip: 10.0.1.4 - mac: DE:8B:9E:19:55:1D - tap: true Node1: ipinterface: enp1s0 ip: 10.0.1.5 mac: FA:EC:43:87:4D:2D tap: true + ups: 'aps' Node2: ipinterface: enp1s0 ip: 10.0.1.7 mac: 56:02:ef:2c:1f:7c tap: true + ups: 'cyberpower' Node3: ipinterface: enp1s0 ip: 10.0.1.8 @@ -123,7 +120,6 @@ all: - '-drive format=raw,index=0,media=disk,file=/dev/sdb' - '-drive format=raw,index=0,media=disk,file=/dev/sdc' - '-drive format=raw,index=0,media=disk,file=/dev/sdd' - geth_hubs: # 10.0.1.32/28 vars: motion_enabled: yes @@ -263,7 +259,7 @@ all: Tachikoma: ip: 10.0.1.72 mac: 90:0f:0c:1a:d3:23 - Dedsec: + DedSec: ip: 10.0.1.73 mac: 34:F6:4B:36:12:8F # dhcp build space: 10.0.1.224/27 @@ -278,6 +274,7 @@ all: Charon: ip: 10.0.2.4 mac: 64:52:99:14:28:2B - Skitarii-1: + # CanoptekAleph: physical, no network + CanoptekBek: ip: 10.0.2.5 mac: 40:9F:38:95:06:34 diff --git a/playbooks/deploy.yml b/playbooks/deploy.yml index ecd469a..889d068 100644 --- a/playbooks/deploy.yml +++ b/playbooks/deploy.yml @@ -57,7 +57,7 @@ roles: - Geth-Hub -- hosts: Node0 +- hosts: Node1,Node2,Node3 order: sorted serial: "{{ threads | default('16') }}" gather_facts: true diff --git a/roles/Sharingan/files/monit/checks/cyberpower b/roles/Sharingan/files/monit/checks/cyberpower new file mode 100644 index 0000000..82af43b --- /dev/null +++ b/roles/Sharingan/files/monit/checks/cyberpower @@ -0,0 +1,2 @@ +check program cyberpower with path "/etc/monit.d/scripts/check-cyberpower" + if status != 0 for 5 times within 5 cycles then exec "/etc/monit.d/scripts/critical Host is on UPS power!" diff --git a/roles/Sharingan/files/monit/hostdefs/Node2 b/roles/Sharingan/files/monit/hostdefs/Node2 index 4229188..4803bb5 100644 --- a/roles/Sharingan/files/monit/hostdefs/Node2 +++ b/roles/Sharingan/files/monit/hostdefs/Node2 @@ -1 +1,2 @@ include "/etc/monit.d/checks/system" +include "/etc/monit.d/checks/cyberpower" diff --git a/roles/Sharingan/files/monit/scripts/check-cyberpower b/roles/Sharingan/files/monit/scripts/check-cyberpower new file mode 100755 index 0000000..85cb543 --- /dev/null +++ b/roles/Sharingan/files/monit/scripts/check-cyberpower @@ -0,0 +1,6 @@ +#!/bin/bash + +if [ `pwrstat -status | sed 's/^\s\+//' | grep -E ^State | awk '{ print $2; }'` != 'Normal' ]; then + exit 2; +fi +exit 0 diff --git a/roles/hardware/tasks/amd.yml b/roles/hardware/tasks/amd.yml new file mode 100644 index 0000000..7eb54d9 --- /dev/null +++ b/roles/hardware/tasks/amd.yml @@ -0,0 +1,13 @@ +--- + + - name: AMD Ucode + become: yes + register: amd_ucode + package: + name: amd-ucode + state: present + + - name: Rebuild grub + become: yes + when: amd_ucode.changed + command: grub-mkconfig -o /boot/grub/grub.cfg diff --git a/roles/hardware/tasks/cyberpower.yml b/roles/hardware/tasks/cyberpower.yml new file mode 100644 index 0000000..6014df9 --- /dev/null +++ b/roles/hardware/tasks/cyberpower.yml @@ -0,0 +1,14 @@ +--- + + - name: Install software + become: yes + package: + name: powerpanel + state: present + + - name: Start service + become: yes + service: + name: pwrstatd.service + state: started + enabled: yes diff --git a/roles/hardware/tasks/intel.yml b/roles/hardware/tasks/intel.yml new file mode 100644 index 0000000..3959085 --- /dev/null +++ b/roles/hardware/tasks/intel.yml @@ -0,0 +1,13 @@ +--- + + - name: Intel Ucode + become: yes + register: intel_ucode + package: + name: intel-ucode + state: present + + - name: Rebuild grub + become: yes + when: intel_ucode.changed + command: grub-mkconfig -o /boot/grub/grub.cfg diff --git a/roles/hardware/tasks/main.yml b/roles/hardware/tasks/main.yml index b8cec13..d965fad 100644 --- a/roles/hardware/tasks/main.yml +++ b/roles/hardware/tasks/main.yml @@ -6,7 +6,6 @@ name: - smartmontools - hdparm - - apcupsd state: present - name: Set udev settings for drives @@ -31,4 +30,15 @@ when: udev_iosched.changed + - include_tasks: amd.yml + when: "'AMD' in ansible_processor[1]" + - include_tasks: intel.yml + when: "'Intel' in ansible_processor" + + + - include_tasks: cyberpower.yml + when: "ups == 'cyberpower'" + + - include_tasks: aps.yml + when: "ups == 'aps'"