Assigning IP Addresses to Hosts

18 views
Skip to first unread message

goo...@iloveyatoo.com

unread,
Apr 24, 2018, 10:36:38 PM4/24/18
to Salt-users
Hi,

I'm looking for a way to automatically assign static IP addresses to minions. The minions are connected via a public IP, but I wish to assign internal IPs to a network formed by a VPN.
Is there any good way to automatically assign IP addresses from a pool to minions (including ip removal on minion removal/etc)?

I've looked into DHCP (not that secure), which I don't really want to use. In addition, the mac addresses are not static between boots (randomly generated), so there may be a lot of churn.

There is also the option of salt execution modules, but I am worried that there can be a race condition between two nodes trying to join at the same time, or offline nodes not reporting their IP.

Is there anything else I can use to assign IPs?

Thanks!

Jeremy McMillan

unread,
Apr 25, 2018, 9:15:41 AM4/25/18
to Salt-users
You want to reinvent DHCP running on salt.

Use a DDNS service and an internal zone as a registry of minions to internal-IP if you need DNS, or mine the assigned internal IPs and store the assignment in a grain.

Use a python pillar.sls (assigned only to minions without the internal IP grain) to look up the existing IP or iteratively search for an available one. To deal with races, listen for and fire events to advertise the IP searching, and implement a randomized progressive wait-retry loop until there are no competing IP search events for two consecutive retry iterations. Then tell the minion to grains.set the chosen IP, and mine.update or update DDNS to advertise the IP assignment.
Reply all
Reply to author
Forward
0 new messages