Cloning without cloud-init or with the service misconfigured can cause certain issues. One of these affects password resets: the option will not work or assign a new password, and you will need to use the original credentials. It will also neither reconfigure the network interface nor be able to resize the server's disk automatically.
In this article, we will explain how to resolve network issues when cloning a server whose cloud-init service has a problem.
Fixing the netplan configuration on the destination server
In this case, netplan will have the previous server's configuration and will not obtain an IP address via DHCP, so you will need to access the cloned server through the emergency console. Then delete the netplan file containing the configuration with the previous server's physical address:
# rm /etc/netplan/50-cloud-init.yaml
Finally, apply the changes to netplan:
# netplan apply
Once this is done, it should obtain an IP address automatically via DHCP, and you will be able to access it over the network in question. You can check this with:
# ip a
The Ethernet interface should appear with the IP address assigned by DHCP:
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether fa:1X:3X:7f:81:XX brd ff:ff:ff:ff:ff:ff
inet 161.22.42.XX/23 brd 161.22.43.255 scope global eth0
valid_lft forever preferred_lft forever
inet6 feX0::Xe16:3eXX:fe7f:81XX/64 scope link
valid_lft forever preferred_lft forever
Fixing the netplan configuration on the source server
Another option is to modify the cloud-init configuration file for netplan and disable it on the source server (if you have the cloud-init service installed).
Edit the configuration file:
# vi /etc/cloud/cloud.cfg.d/99-clouding.cfg
To disable it, add:
network:
config: disabled
You can then clone the server. Without netplan, the system will automatically configure the new interface on the cloned server and obtain an IP address automatically via DHCP.