RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1565746 - Hostname not set by cloud-init on Red Hat Enterprise Linux 7.5 KVM Guest Image
Summary: Hostname not set by cloud-init on Red Hat Enterprise Linux 7.5 KVM Guest Image
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: cloud-init
Version: 7.5
Hardware: x86_64
OS: Linux
unspecified
low
Target Milestone: rc
: ---
Assignee: Ryan McCabe
QA Contact: xiachen
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-04-10 16:27 UTC by Nick Curry
Modified: 2024-11-20 07:53 UTC (History)
9 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-05-09 08:30:33 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Nick Curry 2018-04-10 16:27:54 UTC
Description of problem:
The hostname of the rhel-server-7.5-x86_64-kvm.qcow2 guest image is not set properly by cloud-init when using NoCloud cloud-init data source.

Version-Release number of selected component (if applicable):
Red Hat Enterprise Linux Server release 7.5 (Maipo)
cloud-init-0.7.9-24.el7.x86_64

How reproducible:
Consisently

Steps to Reproduce:
1. Download Red Hat Enterprise Linux 7.5 KVM Guest Image
2. Create cloud-init files (user-data, meta-data)
3. Create cidata.iso from user-data/meta-data
4. Create KVM guest from rhel-server-7.5-x86_64-kvm.qcow2 and cidata.iso
5. Log in and check hostname

Actual results:
Virtual machine has hostname localhost

Expected results:
Virtual machine has hostname set in meta-data

Additional info:
cloud-init install logs

[   14.225839] cloud-init[557]: Cloud-init v. 0.7.9 running 'init-local' at Tue, 10 Apr 2018 16:24:03 +0000. Up 14.19 seconds.
[   14.655545] random: crng init done
[  OK  ] Started Initial cloud-init job (pre-networking).
[  OK  ] Reached target Network (Pre).
         Starting Network Manager...
         Starting Hostname Service...
[  OK  ] Started Hostname Service.
[  OK  ] Started Network Manager.
         Starting Network Manager Script Dispatcher Service...
         Starting Network Manager Wait Online...
[  OK  ] Started Network Manager Script Dispatcher Service.
[   15.094578] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
[  OK  ] Started Network Manager Wait Online.
         Starting LSB: Bring up/down networking...
[  OK  ] Started LSB: Bring up/down networking.
         Starting Initial cloud-init job (metadata service crawler)...
[  OK  ] Reached target Network.
         Starting Postfix Mail Transport Agent...
         Starting Dynamic System Tuning Daemon...
[  OK  ] Started Dynamic System Tuning Daemon.
[   19.185066] cloud-init[826]: Cloud-init v. 0.7.9 running 'init' at Tue, 10 Apr 2018 16:24:08 +0000. Up 19.15 seconds.
[   19.267279] cloud-init[826]: ci-info: ++++++++++++++++++++++++++++++++Net device info++++++++++++++++++++++++++++++++
[   19.269644] cloud-init[826]: ci-info: +--------+------+-----------------+---------------+-------+-------------------+
[   19.274989] cloud-init[826]: ci-info: | Device |  Up  |     Address     |      Mask     | Scope |     Hw-Address    |
[   19.278083] cloud-init[826]: ci-info: +--------+------+-----------------+---------------+-------+-------------------+
[   19.290851] cloud-init[826]: ci-info: |  lo:   | True |    127.0.0.1    |   255.0.0.0   |   .   |         .         |
[   19.292705] cloud-init[826]: ci-info: |  lo:   | True |        .        |       .       |   d   |         .         |
[   19.294491] cloud-init[826]: ci-info: | eth0:  | True | 192.168.122.146 | 255.255.255.0 |   .   | 52:54:00:e9:14:2e |
[   19.296305] cloud-init[826]: ci-info: | eth0:  | True |        .        |       .       |   d   | 52:54:00:e9:14:2e |
[   19.297997] cloud-init[826]: ci-info: +--------+------+-----------------+---------------+-------+-------------------+
[   19.299727] cloud-init[826]: ci-info: +++++++++++++++++++++++++++++++Route IPv4 info+++++++++++++++++++++++++++++++
[   19.322914] cloud-init[826]: ci-info: +-------+---------------+---------------+---------------+-----------+-------+
[   19.324990] cloud-init[826]: ci-info: | Route |  Destination  |    Gateway    |    Genmask    | Interface | Flags |
[   19.327533] cloud-init[826]: ci-info: +-------+---------------+---------------+---------------+-----------+-------+
[   19.329221] cloud-init[826]: ci-info: |   0   |    0.0.0.0    | 192.168.122.1 |    0.0.0.0    |    eth0   |   UG  |
[   19.344147] cloud-init[826]: ci-info: |   1   | 192.168.122.0 |    0.0.0.0    | 255.255.255.0 |    eth0   |   U   |
[   19.346390] cloud-init[826]: ci-info: +-------+---------------+---------------+---------------+-----------+-------+
[  OK  ] Started Postfix Mail Transport Agent.
[  OK  ] Started Initial cloud-init job (metadata service crawler).
         Starting Permit User Sessions...
[  OK  ] Reached target Cloud-config availability.
         Starting OpenSSH Server Key Generation...
[  OK  ] Reached target Network is Online.
         Starting Apply the settings specified in cloud-config...
         Starting Notify NFS peers of a restart...
         Starting Crash recovery kernel arming...
         Starting System Logging Service...
         Starting LSB: Starts the Spacewalk Daemon...
[  OK  ] Started Permit User Sessions.
[  OK  ] Started Notify NFS peers of a restart.
[  OK  ] Started Serial Getty on ttyS0.
         Starting Serial Getty on ttyS0...
[  OK  ] Started Command Scheduler.
         Starting Command Scheduler...
[  OK  ] Started Getty on tty1.
         Starting Getty on tty1...
[  OK  ] Reached target Login Prompts.
[  OK  ] Started System Logging Service.
[  OK  ] Started LSB: Starts the Spacewalk Daemon.
[   21.191628] cloud-init[1030]: Cloud-init v. 0.7.9 running 'modules:config' at Tue, 10 Apr 2018 16:24:10 +0000. Up 20.99 seconds.
[  OK  ] Started OpenSSH Server Key Generation.
         Starting OpenSSH server daemon...
[  OK  ] Started OpenSSH server daemon.
         Stopping OpenSSH server daemon...
[  OK  ] Stopped OpenSSH server daemon.
[  OK  ] Stopped OpenSSH Server Key Generation.
         Stopping OpenSSH Server Key Generation...
         Starting OpenSSH server daemon...
[  OK  ] Started OpenSSH server daemon.
[  OK  ] Started Apply the settings specified in cloud-config.
         Starting Execute cloud user/final scripts...
[   21.740263] cloud-init[1149]: Cloud-init v. 0.7.9 running 'modules:final' at Tue, 10 Apr 2018 16:24:11 +0000. Up 21.67 seconds.
ci-info: ++++++++++++Authorized keys from /home/ncc/.ssh/authorized_keys for user ncc+++++++++++++
ci-info: +---------+-------------------------------------------------+---------+-----------------+
ci-info: | Keytype |                Fingerprint (md5)                | Options |     Comment     |
ci-info: +---------+-------------------------------------------------+---------+-----------------+
ci-info: | ssh-rsa | 9c:57:8d:c8:32:d7:3d:86:a8:e8:02:eb:47:7d:82:04 |    -    | ncc@nixtopt460s |
ci-info: +---------+-------------------------------------------------+---------+-----------------+
ec2: 
ec2: #############################################################
ec2: -----BEGIN SSH HOST KEY FINGERPRINTS-----
...
ec2: -----END SSH HOST KEY FINGERPRINTS-----
ec2: #############################################################
-----BEGIN SSH HOST KEY KEYS-----
...
-----END SSH HOST KEY KEYS-----
[   21.841077] cloud-init[1149]: Cloud-init v. 0.7.9 finished at Tue, 10 Apr 2018 16:24:11 +0000. Datasource DataSourceNoCloud [seed=/dev/sr0][dsmode=net].  Up 21.83 seconds
[  OK  ] Started Execute cloud user/final scripts.
[  OK  ] Reached target Multi-User System.
         Starting Update UTMP about System Runlevel Changes...
[  OK  ] Started Update UTMP about System Runlevel Changes.

Red Hat Enterprise Linux Server 7.5 (Maipo)
Kernel 3.10.0-862.el7.x86_64 on an x86_64

Comment 2 Nick Curry 2018-04-10 16:43:19 UTC
Using 

local-hostname instead of hostname in user-data fixed the issue

Comment 3 xiachen 2020-05-09 08:30:33 UTC
According cloud-init doc, https://cloudinit.readthedocs.io/en/latest/topics/datasources/nocloud.html
for NoCloud data source, the permitted key is h or local-hostname.
so using local-hostname instead of hostname in user-data fixed the issue.

Close this bug as NOTABUG.

Comment 4 jeannette9728miller 2024-05-13 12:51:16 UTC
The issue you’re describing with cloud-init not setting the hostname properly on a Red Hat Enterprise Linux 7.5 KVM Guest Image is a known problem. The bug report indicates that the status is CLOSED NOTABUG, which typically means that the behavior experienced is not considered a bug by the developers or it could not be reproduced.

The version of cloud-init you’re using (0.7.9-24.el7.x86_64) might have known issues with setting the hostname. Check if there’s an updated version available and consider updating it.
Make sure that the user-data and meta-data files are correctly configured. The meta-data file should contain a line like hostname: desired-hostname to set the hostname.
The logs you’ve provided indicate that cloud-init is running its modules. Look for any errors or warnings in the logs that might point to why the hostname isn’t being set.
If cloud-init fails to set the hostname, you can manually set it by editing the /etc/hostname file and then running hostnamectl set-hostname desired-hostname.

Remember to replace desired-hostname with the actual hostname you want to set for your virtual machine.


Note You need to log in before you can comment on or make changes to this bug.