I'm using HashiCorp Packer to create a QEMU VM running AlmaLinux 9. After setting it up with a kickstart file and provisioning with Ansible, I save it as a qcow2 image and upload it to Google Cloud, before downloading it on Vultr. However, once I launch the server from the snapshot, I'm unable to SSH into it because it times out. When I check the network status, it seems that my VPS isn't connecting properly to the Vultr Ethernet device. The Ethernet device shows as 'enp1s0', but the configuration is for 'enp0s3'. I've figured out how to manually fix this issue, but I'm looking for a way to automate the process during provisioning without needing to log in manually. I tried writing a bash script to address this issue, but I'm open to better solutions, especially using Ansible or nmcli. Any suggestions?
1 Answer
To avoid this issue during your image build, consider removing the old network interface configuration when finalizing your setup with Packer. By deleting the existing connection and NIC before shutting down the VM, the system should create a new interface with the correct name upon deployment, allowing cloud-init and Network Manager to automatically configure it with DHCP.
Sounds like a good plan! Would doing something like `rm -rf /etc/NetworkManager/system-connections` followed by `mkdir /etc/NetworkManager/system-connections` work for that?