Over the last year at work, we have really stepped up our automation efforts.
It started out with OS customization using Ansible, but we quickly ran into the issue of bootstrapping the network configuration.
We were cloning a minimally configured RHEL 7 template to deploy new machines, but we would have to manually login through the remote console to set the IP and also change the VLAN in the admin console.
However, we were on a mission from God to touch the machines as little as possible in the name of real automation, so even that small amount of manual intervention galled us.
This post is mostly to go through the PowerCLI script that I wrote (with some help) to deploy RHEL 7 VMs with networking configured as an automated customization process. Starting out, I had a few goals in mind:
- Deploy multiple virtual machines in one process
- Specify all details in one CSV file
- Be able to SSH into the machine immediately after deployment
Edit 2020-08-04: I’ve removed the code from this post, see my git repo for the code.
Now there’s definitely room for improvement. For one thing, this script proceeds serially through the CSV file, deploying each machine and waiting for customization to complete. That’s not great if you want to deploy hundreds of machines (although at that point you are most likely doing this in a more efficient manner anyway). Another area that could be improved is the heurisitcs. In this case, it requires you to know the portgroup name for each VLAN, which is not ideal. I would love to tie this in with our Netbox DCIM/IPAM application, as that system accurately tracks all of our VLANs, IPs, and virtual machines. The big problem there is that out vCenter inventory does not always map one-to-one with what is in Netbox, so… yeah.