From 7ea78010e2a9027282bcd9635c211d1b1d2cde44 Mon Sep 17 00:00:00 2001 From: Tobias Schwarz Date: Sat, 17 Aug 2024 12:24:57 +0000 Subject: [PATCH] model: add requires_mac_override setting --- .github/checks/check-mac-override-missing.sh | 46 ++++++++++++++++++++ group_vars/model_dlink_covr_x1860_a1.yml | 2 + group_vars/model_mikrotik_sxtsq_2_lite.yml | 2 + group_vars/model_mikrotik_sxtsq_5_ac.yml | 2 + group_vars/model_netgear_wax202.yml | 2 + group_vars/model_netgear_wax220.yml | 2 + 6 files changed, 56 insertions(+) create mode 100755 .github/checks/check-mac-override-missing.sh diff --git a/.github/checks/check-mac-override-missing.sh b/.github/checks/check-mac-override-missing.sh new file mode 100755 index 000000000..0891c377e --- /dev/null +++ b/.github/checks/check-mac-override-missing.sh @@ -0,0 +1,46 @@ +#!/bin/bash + +# Initialize a variable to track if any errors are found +error_found=0 + +location_files='locations/*.yml' + +# Loop through all location YAML files +for location_file in $location_files; do + # Extract host information using yq + host_count=$(yq '.hosts | length' "$location_file") + + # Loop through each host entry + for ((i=0; i<$host_count; i++)); do + hostname=$(yq ".hosts[$i].hostname" "$location_file") + model=$(yq ".hosts[$i].model" "$location_file") + mac_override=$(yq ".hosts[$i].mac_override" "$location_file") + + # Convert model name to match the model file format + model_file=$(echo "$model" | sed 's/-/_/g' | sed 's/"//g') + model_file_path="group_vars/model_${model_file}.yml" + + # Check if the model file exists, otherwise continue + if [ ! -f "$model_file_path" ]; then + continue + fi + + # Check if the model requires mac_override + requires_mac_override=$(yq '.requires_mac_override' "$model_file_path") + + if [ "$requires_mac_override" = "true" ]; then + if [ "$mac_override" == "null" ]; then + # Output the missing mac_override details immediately + echo "Host $hostname (model: $model) in $location_file is missing mac_override." + error_found=1 + fi + fi + done +done + +# Exit with a non-zero status code if any errors were found +if [ "$error_found" -eq 1 ]; then + exit 1 +else + echo "No MAC override issues found." +fi diff --git a/group_vars/model_dlink_covr_x1860_a1.yml b/group_vars/model_dlink_covr_x1860_a1.yml index 5cc79763e..1be42f690 100644 --- a/group_vars/model_dlink_covr_x1860_a1.yml +++ b/group_vars/model_dlink_covr_x1860_a1.yml @@ -8,6 +8,8 @@ dsa_ports: - internet - ethernet +requires_mac_override: true + wireless_devices: - name: 11a_standard band: 5g diff --git a/group_vars/model_mikrotik_sxtsq_2_lite.yml b/group_vars/model_mikrotik_sxtsq_2_lite.yml index 954e7aa42..07d19117e 100644 --- a/group_vars/model_mikrotik_sxtsq_2_lite.yml +++ b/group_vars/model_mikrotik_sxtsq_2_lite.yml @@ -6,6 +6,8 @@ model_nice: SXTsq Lite2 int_port: eth0 +requires_mac_override: true + wireless_devices: - name: 11g_standard band: 2g diff --git a/group_vars/model_mikrotik_sxtsq_5_ac.yml b/group_vars/model_mikrotik_sxtsq_5_ac.yml index 820a390bd..028417759 100644 --- a/group_vars/model_mikrotik_sxtsq_5_ac.yml +++ b/group_vars/model_mikrotik_sxtsq_5_ac.yml @@ -10,6 +10,8 @@ model__packages__to_merge: dsa_ports: - lan +requires_mac_override: true + wireless_devices: - name: 11a_standard band: 5g diff --git a/group_vars/model_netgear_wax202.yml b/group_vars/model_netgear_wax202.yml index 67738a5e7..744b086ae 100644 --- a/group_vars/model_netgear_wax202.yml +++ b/group_vars/model_netgear_wax202.yml @@ -9,6 +9,8 @@ dsa_ports: - lan2 - lan3 +requires_mac_override: true + wireless_devices: - name: 11a_standard band: 5g diff --git a/group_vars/model_netgear_wax220.yml b/group_vars/model_netgear_wax220.yml index d91c356b1..02640c5cc 100644 --- a/group_vars/model_netgear_wax220.yml +++ b/group_vars/model_netgear_wax220.yml @@ -4,6 +4,8 @@ brand_nice: NETGEAR model_nice: WAX220 int_port: eth0 +requires_mac_override: true + wireless_devices: - name: 11a_standard band: 5g