Help Center> Virtual Private Cloud> FAQs> Connectivity> Why Can't My ECS Use Cloud-init?
Updated on 2022-06-24 GMT+08:00

Why Can't My ECS Use Cloud-init?

Symptom

An ECS is not able to use cloud-init.

Troubleshooting

Figure 1 shows the process for an ECS to obtain metadata using the cloud-init.
Figure 1 Process for obtaining metadata

Check the following possible causes.

Figure 2 Possible causes
Table 1 Possible causes

Possible Cause

Solution

The ECS has no IP address obtained.

See The ECS Has Not Obtained IP Address

Incorrect route for 169.254.169.254

See Incorrect Route for 169.254.169.254

Fail to obtain the ECS metadata.

See Did Not 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.

Figure 3 ECS IP address

Incorrect Route for 169.254.169.254

Ping 169.254.169.254/32 from the ECS. If the IP address cannot be pinged, perform the following steps:
  1. 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
  2. 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.

  3. 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.
    • If the ECS is newly created, submit a service ticket or contact technical support.

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.

Figure 5 Command output

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.

Figure 6 Configuration file

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.

Submitting a Service Ticket

If the EIP still fails to use cloud-init after performing the preceding steps, submit a service ticket.

Provide the following information to the technical support engineer.

Item

Description

Example

Value

VPC CIDR block

Required for customer gateway configuration

Example: 10.0.0.0/16

N/A

VPC ID

N/A

Example: 120b71c7-94ac-45b8-8ed6-30aafc8fbdba

N/A

CIDR block of subnet 1 (can be the same as the VPC CIDR block)

N/A

Example: 10.0.1.0/24

N/A

ECS ID

N/A

N/A

N/A

ECS IP address

N/A

Example: 192.168.1.192/24

N/A

ECS route information

N/A

N/A

-

Connectivity FAQs

more