Why Can't My ECS Use Cloud-init?
Symptom
An ECS is not able to use cloud-init.
Troubleshooting
Check the following possible causes.
Possible Cause |
Solution |
---|---|
The ECS has no IP address obtained. |
|
Incorrect route for 169.254.169.254 |
|
Fail to obtain the ECS metadata. |
|
Fail to log in to the ECS or create a non-root user after cloud-init is configured. |
Check the format of the /etc/cloud/cloud.cfg configuration file. For details, see Cannot Log in to the ECS or Create a Non-root User After Cloud-init Is Configured. |
Fail to use an obtained private key to log in to an ECS after the ECS starts (Fail to obtain the ECS login password). |
Restart the ECS and try again. |
The ECS Has Not Obtained IP Address
Check whether the ECS has obtained an IP address.
If no IP address is obtained, run the dhclient command to obtain the IP address (this command varies depending on the ECS OSs). Alternatively, you can run the ifdown ethx command to disable the network port and then run the ifup ethx command to enable it to allow the ECS NIC to automatically obtain an IP address again.
Incorrect Route for 169.254.169.254
- Check the exact route configured on the ECS for IP address 169.254.169.254/32.
In most cases, the next hop of the exact route for IP address 169.254.169.254/32 is the same as that of the default route for the IP address.
Figure 4 Route for IP address 169.254.169.254/32
- If there is no exact route for IP address 169.254.169.254/32, the cause is as follows:
Images with CentOS 5 OSs are not compatible with cloud-init. To use cloud-init, select a different OS.
- If the next hop of the exact route for IP address 169.254.169.254/32 is different from that of the default route for the IP address:
- If the ECS was created before cloud-init was enabled, run service network restart to obtain the correct route.
Did Not Obtain the ECS Metadata
Run the following command on the ECS to obtain the metadata:
curl http://169.254.169.254/openstack/latest/meta_data.json
If information similar to that shown in Figure 5 is displayed, the ECS successfully obtains the metadata.
Cannot Log in to the ECS or Create a Non-root User After Cloud-init Is Configured
Check whether the /etc/cloud/cloud.cfg configuration file format is correct. For details, see the file format requirements for different Linux distributions. The following figure shows an example /etc/cloud/cloud.cfg configuration file for Ubuntu.
Obtained Private Key Cannot Be Used to Log in to an ECS After the ECS Starts (Failed to Obtain the ECS Login Password)
Restart the ECS to rectify the fault.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.