BCDevOps / developer-experience

This repository is used to track all work for the BCGov Platform Services Team (This includes work for: 1. Platform Experience, 2. Developer Experience 3. Platform Operations/OCP 3)
Apache License 2.0
8 stars 17 forks source link

Build a tool / github action to double check new node IPs aren't duplicates #4336

Open StevenBarre opened 11 months ago

StevenBarre commented 11 months ago

Describe the issue When adding new nodes with dhcp stuff, we need to double check that we aren't adding duplicate IPs. https://github.com/bcgov-c/rhcos-ignition-builder/pull/120

What is the Value/Impact? Prevent duplicate IPs in DHCP config

What is the plan? How will this get completed? Can we create a github action to lint PRs and alert if there are duplicate IPs in the inventory files

Identify any dependencies None

Definition of done

StevenBarre commented 8 months ago

Not sure how we'll be able to detect duplicates with IPs not listed in the INV files?

vivekratan88 commented 2 months ago

https://blog.ktz.me/check-for-duplicate-items-in-a-list-with-ansible-using-a-custom-filter/

tbaker1313 commented 1 month ago

In the inventory files, the ip addresses are in the line containing 'ip:' so we can extract that data and feed it to awk something like this:

grep -R "ip:" inventory/host_vars/* | awk -F ':' '{if($3 in x){if(x[$3]) print x[$3]; print;x[$3]=""} else x[$3]=$0}'

The one issue here is that klab2 and emerald share a bootstrap ip address - could be filtered out with an inverse grep if desired.

tbaker1313 commented 1 month ago

Had to try another approach to this as the last effort didn't yield a working result on the first test. Added a new workflow to test and am attempting to determine why the second task isn't running the way I think it should.

tbaker1313 commented 1 month ago

Created a new repo for testing https://github.com/tbaker1313/test-actions