-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
model: add requires_mac_override setting
- Loading branch information
Showing
6 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,8 @@ dsa_ports: | |
- lan2 | ||
- lan3 | ||
|
||
requires_mac_override: true | ||
|
||
wireless_devices: | ||
- name: 11a_standard | ||
band: 5g | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters