From 5089c82710f1d21ca8d122cae798e3489fe814de Mon Sep 17 00:00:00 2001 From: DarkFeather Date: Tue, 15 Apr 2025 13:59:53 -0500 Subject: [PATCH] Inventory sanity checks --- examples/msn0.yml | 64 ++++++++++++++++++---------------- playbooks/verify-inventory.yml | 52 +++++++++++++++++++++++++++ 2 files changed, 86 insertions(+), 30 deletions(-) create mode 100644 playbooks/verify-inventory.yml diff --git a/examples/msn0.yml b/examples/msn0.yml index d4372b2..43df3b7 100644 --- a/examples/msn0.yml +++ b/examples/msn0.yml @@ -46,7 +46,7 @@ all: Chappaai: ipinterface: eth0 ip: 10.0.1.2 - mac: B8:27:EB:B6:AA:0C + mac: e4:5f:01:01:ff:9b static: true children: Node: @@ -54,7 +54,7 @@ all: Node1: ipinterface: enp1s0 ip: 10.0.1.5 - mac: FA:EC:43:87:4D:2D + mac: fa:ec:43:87:4d:2d tap: true ups: 'aps' active_vms: @@ -72,7 +72,7 @@ all: Node3: ipinterface: enp1s0 ip: 10.0.1.8 - mac: B2:C6:2C:02:B2:6E + mac: b2:c6:2c:02:b2:6e tap: true active_vms: - TDS-Jump @@ -81,33 +81,33 @@ all: Geth0: ipinterface: eth0 ip: 10.0.1.9 - mac: 84:16:F9:14:15:C5 + mac: b8:27:eb:09:a1:a0 static: true k3s_primary: true Geth1: ipinterface: eth0 ip: 10.0.1.10 - mac: E4:5F:01:01:FF:9C + mac: e4:5f:01:01:ff:9c static: true Geth2: ipinterface: eth0 ip: 10.0.1.11 - mac: E4:5F:01:01:FF:D5 + mac: e4:5f:01:01:ff:d5 static: true Geth3: ipinterface: eth0 ip: 10.0.1.12 - mac: E4:5F:01:01:FF:96 + mac: e4:5f:01:01:ff:96 static: true Geth4: ipinterface: eth0 ip: 10.0.1.13 - mac: E4:5F:01:01:FF:E4 + mac: e4:5f:01:01:ff:e4 static: true Geth5: ipinterface: eth0 ip: 10.0.1.14 - mac: B8:27:EB:B6:AA:0D + mac: b8:27:eb:81:f5:4b static: true virtual: # 10.0.1.16/28 vars: @@ -115,7 +115,7 @@ all: Sharingan: ip: 10.0.1.16 ipinterface: ens3 - mac: 00:15:5D:01:02:10 + mac: 00:15:5d:01:02:10 cores: 4 memory: 4 vnc: 8 @@ -129,7 +129,7 @@ all: DarkNet: ipinterface: ens3 ip: 10.0.1.17 - mac: 00:15:5D:01:02:05 + mac: 00:15:5d:01:02:05 cores: 4 memory: 4 vnc: 9 @@ -153,12 +153,12 @@ all: ip: 10.0.1.3 mac: 00:25:90:0d:6e:86 static: true - sslidentity: aninix.net-0001 + sslidentity: aninix.net-0002 secdetection: true - iptv_location: "Milwaukee|Madison" + iptv_location: "ToonamiAftermathEast.us|TVSClassicMovies.us|UniversalComedy|ABCNewsLive" aether_source: true cores: 8 - memory: 16 + memory: 10 bridge: br0 vnc: 1 vscan_enabled: true @@ -173,12 +173,12 @@ all: hosts: Vergil1: ip: 10.0.1.32 - mac: b8:27:eb:9a:73:dd + mac: b8:27:eb:e3:ff:59 rotate: 0 remote: NS-RC4NA-14 Vergil2: ip: 10.0.1.33 - mac: 84:16:F9:13:B6:E6 + mac: b8:27:eb:cf:26:88 motion_enabled: no rotate: 180 remote: NS-RC4NA-14 @@ -194,7 +194,7 @@ all: hosts: Superintendent: ip: 10.0.1.49 - mac: DE:8B:9E:19:55:1E + mac: de:8b:9e:19:55:1e cores: 2 memory: 2 vnc: 6 @@ -271,10 +271,10 @@ all: mac: 2c:30:33:64:f4:03 Print: # Print is excepted for legacy setup reasons before we laid out subnets. ip: 10.0.1.6 - mac: 00:80:92:77:CE:E4 + mac: 00:80:92:77:ce:e4 Geth-Eyes: ip: 10.0.1.68 - mac: 9C:A3:AA:33:A3:99 + mac: 9c:a3:aa:33:a3:99 # "Core-Console": # ip: 10.0.1.74 # mac: 00:25:90:0D:82:5B @@ -288,38 +288,42 @@ all: mac: f4:2b:8c:10:31:44 Lykos: ip: 10.0.1.65 - mac: 70:74:14:4F:8E:42 + mac: 70:74:14:4f:8e:42 Node0: ip: 10.0.1.66 - mac: E0:BE:03:77:0E:88 + mac: e0:be:03:77:0e:88 LivingRoomTV: ip: 10.0.1.69 - mac: 80:D2:1D:17:63:0E + mac: 80:d2:1d:17:63:0e BedRoomTV: ip: 10.0.1.70 - mac: 80:D2:1D:17:63:0F + mac: a4:77:33:4c:2a:44 TrainingRoomTV: ip: 10.0.1.71 - mac: 80:D2:1D:17:63:10 + mac: 80:d2:1d:17:63:10 BT: ip: 10.0.1.72 - mac: 8A:00:AA:7F:DF:D1 + mac: 8a:00:aa:7f:df:d1 DedSec: ip: 10.0.1.73 - mac: 34:F6:4B:36:12:8F + mac: d4:e9:8a:7d:79:b3 # dhcp build space: 10.0.1.224/27 iot: # 10.0.2.0/24 hosts: + # Nest Thermostat LivingRoomRegulator: ip: 10.0.2.2 - mac: 64:16:66:08:57:F5 + mac: 64:16:66:08:57:f5 + # Nest Protect Monitor: ip: 10.0.2.3 - mac: 18:B4:30:2F:F1:37 + mac: 18:b4:30:2f:f1:37 + # Chamberlain My-Q Gatekeeper: ip: 10.0.2.4 - mac: 64:52:99:14:28:2B + mac: 64:52:99:14:28:2b # CaretakerAlpha has no network + # iRobot Roomba CaretakerBravo: ip: 10.0.2.5 - mac: 40:9F:38:95:06:34 + mac: 40:9f:38:95:06:34 diff --git a/playbooks/verify-inventory.yml b/playbooks/verify-inventory.yml new file mode 100644 index 0000000..a162a06 --- /dev/null +++ b/playbooks/verify-inventory.yml @@ -0,0 +1,52 @@ +--- + +- hosts: "{{ targets | default('managed') }}" + become: true + tasks: + + - name: Verify IP + ignore_errors: true + register: status + assert: + that: + - "ip in ansible_default_ipv4.address" + + - debug: + msg: "Inventory IP {{ ip }} for {{ inventory_hostname }} doesn't match configured {{ ansible_default_ipv4.address }}" + when: status.failed + + + - name: Verify MAC + ignore_errors: true + register: status + assert: + that: + - "mac in ansible_default_ipv4.macaddress" + + - debug: + msg: "Inventory MAC {{ mac }} for {{ inventory_hostname }} doesn't match configured {{ ansible_default_ipv4.macaddress }}" + when: status.failed + + - name: Verify cores + ignore_errors: true + when: cores is defined + register: corescheck + assert: + that: + - "cores == ansible_processor_cores" + + - debug: + msg: "Inventory {{ cores }} cores for {{ inventory_hostname }} doesn't match configured {{ ansible_processor_cores }}" + when: cores is defined and corescheck.failed + + - name: Verify memory + ignore_errors: true + register: memcheck + when: memory is defined + assert: + that: + - "memory == (ansible_memtotal_mb - ansible_memtotal_mb % 1000)/ 1000 + 1 " # hasty rounding + + - debug: + msg: "Inventory {{ memory }} GB memory for {{ inventory_hostname }} doesn't match configured {{ (ansible_memtotal_mb - ansible_memtotal_mb % 1000)/ 1000 + 1 }} GB" + when: memory is defined and memcheck.failed