简体   繁体   中英

OpenStack Cloud-Init Set Hostname to VM-Name

How can I set the hostname of a VM to the VM-Name in OpenStack?

I can set the hostname using cloud-init, but I do not know how to set it to a 'parameter', that is, how to make cloud-init / OpenStack pass in the VM-Name.

That's automatically done when OpenStack metadata services are running. As a matter of facts, if your cloud-images are prepared to use cloud-init, your OpenStack services have the Metadata-Services running, and there is no "preserve_hostname: True" in your cloud-init config (normally at /etc/cloud/cloud.cfg)

Any name that you give to the instance, will be passed as "hostname" vía metadata-services to your instance.

Do the following test in any of your instances. Run the following command:

ec2metadata

If that fails, either the cloud-init software is incomplete, or your metadata-services is not reachable from the instances !.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM