Skip to content

Commit f1117ba

Browse files
committed
Refactor NIC check to improve normalization and readability
1 parent 5603dba commit f1117ba

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/roles/configuration_checks/tasks/files/network.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,10 +209,10 @@ checks:
209209
nic=$(basename "$nic_id")
210210
az network nic show --resource-group {{ CONTEXT.resource_group_name }} --name "$nic" \
211211
--query "ipConfigurations[].{IP:privateIPAddress, Primary:primary}" -o tsv |
212-
while IFS=$'\t' read -r ip is_primary; do
213-
# normalize: trim spaces/CR and lowercase
214-
norm=$(echo "$is_primary" | tr -d '\r\t ' | tr '[:upper:]' '[:lower:]')
215-
if [ "$norm" = "true" ]; then
212+
while read -r line; do
213+
ip=$(echo "$line" | awk '{print $1}')
214+
is_primary=$(echo "$line" | awk '{print $2}' | tr -d '\r\t ' | tr '[:upper:]' '[:lower:]')
215+
if [ "$is_primary" = "true" ]; then
216216
echo "$nic: $ip Primary"
217217
else
218218
echo "$nic: $ip Secondary"

0 commit comments

Comments
 (0)