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 1450521 - Cloud-init fails to set hostname on RHEL 7.3/7.4 VM deployed using template
Summary: Cloud-init fails to set hostname on RHEL 7.3/7.4 VM deployed using template
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: cloud-init
Version: 7.3
Hardware: All
OS: Linux
medium
high
Target Milestone: rc
: ---
Assignee: Ryan McCabe
QA Contact: Vladimir
URL:
Whiteboard:
: 1478708 1542657 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-05-12 21:43 UTC by vaibhav
Modified: 2024-11-21 02:54 UTC (History)
21 users (show)

Fixed In Version: cloud-init-0.7.9-18.el7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-04-10 14:05:07 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
log for cloud_init_0.7.9-16test (81.98 KB, text/plain)
2017-11-16 10:51 UTC, Vladimir
no flags Details
/var/log for cloud-init-0.7.9-16test (46.68 KB, application/zip)
2017-11-16 15:48 UTC, Vladimir
no flags Details
fix for the startup ordering (666 bytes, patch)
2018-02-06 17:41 UTC, Ryan McCabe
no flags Details | Diff
patch (666 bytes, patch)
2018-04-04 15:28 UTC, Ryan McCabe
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Red Hat Knowledge Base (Solution) 3118001 0 None None None 2017-09-05 09:29:11 UTC
Red Hat Product Errata RHEA-2018:0806 0 normal SHIPPED_LIVE cloud-init bug fix and enhancement update 2018-04-10 12:40:54 UTC

Description vaibhav 2017-05-12 21:43:13 UTC
Description of problem:
Cloud-init can not set hostname for the RHEL 7.3 VM deployed using template.

Version-Release number of selected component (if applicable):

RHEL 7.3
cloud-init-0.7.9-3.el7.x86_64
How reproducible:


Steps to Reproduce:
1. Create template of RHEL 7.3 which includes cloud-init package 
2. Deploy new VM using template and try to set hostname using cloud-init 
3. Check hostname after successfully deploying VM.

Actual results:
Hostname is not changing using cloud-init 

Expected results:

Hostname should change when using cloud-init for initial setup.

Additional info:

Reproduced issue and getting below traceback error :- 

~~~~~~~~~~~~~~
2017-05-13 02:22:46,834 - helpers.py[DEBUG]: Running config-set_hostname using lock (<FileLock using file '/var/lib/cloud/instances/131558a1-38bb-41f6-bb78-46e6a5e4c307/sem/config_set_hostname'>)
2017-05-13 02:22:46,834 - cc_set_hostname.py[DEBUG]: Setting the hostname to vpagar.localhost.com (vpagar)
2017-05-13 02:22:46,834 - util.py[DEBUG]: Running command ['hostnamectl', 'set-hostname', 'vpagar.localhost.com'] with allowed return codes [0] (shell=False, capture=True)
2017-05-13 02:22:46,840 - util.py[WARNING]: Failed to set the hostname to vpagar.localhost.com (vpagar)
2017-05-13 02:22:46,840 - util.py[DEBUG]: Failed to set the hostname to vpagar.localhost.com (vpagar)
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/cloudinit/config/cc_set_hostname.py", line 47, in handle
    cloud.distro.set_hostname(hostname, fqdn)
  File "/usr/lib/python2.7/site-packages/cloudinit/distros/__init__.py", line 84, in set_hostname
    self._write_hostname(writeable_hostname, self.hostname_conf_fn)
  File "/usr/lib/python2.7/site-packages/cloudinit/distros/rhel.py", line 130, in _write_hostname
    util.subp(['hostnamectl', 'set-hostname', str(hostname)])
  File "/usr/lib/python2.7/site-packages/cloudinit/util.py", line 1850, in subp
    cmd=args)
ProcessExecutionError: Unexpected error while running command.
Command: ['hostnamectl', 'set-hostname', 'vpagar.localhost.com']
Exit code: 1
Reason: -
Stdout: -
Stderr: Failed to create bus connection: No such file or directory
2017-05-13 02:22:46,844 - handlers.py[DEBUG]: finish: init-local/config-set_hostname: FAIL: running config-set_hostname with frequency once-per-instance
~~~~~~~~~~~~~~

Comment 10 Dustin Scott 2017-07-18 13:56:33 UTC
+1 - Had another customer see this issue using CloudForms w/ RHEL 7.3 template provisioning to RHV.  Cloud-init version is cloud-init-0.7.9-3.el7.x86_64.  Confirmed that downgrading to 0.7.6 fixed the issue.

The workaround was to hard-code 'hostnamectl set-hostname hostname.mydomain.com' into the runcmd section of cloud-init, because that part appears to run after dbus is started.  This assumes that the cloud-init template will be ONLY used for RHEL7 and is not being used with other flavors of OS that may not use hostnamectl.

Comment 11 Alex 2017-09-05 10:04:20 UTC
also affecting rhel-7.4 latest

here is another workaround: https://bugs.launchpad.net/cloud-init/+bug/1662542

```
# Deactive Default dependencies

sed -i '/^\[Unit\]$/,/^\[/ s/^DefaultDependencies=no/#DefaultDependencies=no/' /usr/lib/systemd/system/cloud-init.service
sed -i '/^\[Unit\]$/,/^\[/ s/^DefaultDependencies=no/#DefaultDependencies=no/' /usr/lib/systemd/system/cloud-init-local.service

# Remove ordering for sysinit.target

sed -i '/^\[Unit\]$/,/^\[/ s/^Before=sysinit.target/#Before=sysinit.target/' /usr/lib/systemd/system/cloud-init.service
sed -i '/^\[Unit\]$/,/^\[/ s/^Before=sysinit.target/#Before=sysinit.target/' /usr/lib/systemd/system/cloud-init-local.service

# order with systemd-hostnamed.service

sed -i '/^\[Unit\]$/,/^\[/ s/^After=networking.service/After=networking.service\nAfter=systemd-hostnamed.service/' /usr/lib/systemd/system/cloud-init.service
```

Comment 14 Steve Bonneville 2017-10-25 14:02:04 UTC
Red Hat Training is also seeing this issue as we work on the next update of our RHV training course.  We would love to see a fix here before we release the course, otherwise we're going to have to carry information about the regression and the work around in the course.  We also confirm that downgrading from 0.7.9 to 0.7.6 works around the issue.

Comment 16 Israel Pinto 2017-11-07 15:05:15 UTC
*** Bug 1478708 has been marked as a duplicate of this bug. ***

Comment 18 Vladimir 2017-11-16 10:50:20 UTC
Hi, Ryan
I've checked with 0.7.9-16test version and it doesn't update hostname

Comment 19 Vladimir 2017-11-16 10:51:05 UTC
Created attachment 1353409 [details]
log for cloud_init_0.7.9-16test

Comment 20 Ryan McCabe 2017-11-16 14:23:09 UTC
(In reply to Vladimir from comment #19)
> Created attachment 1353409 [details]
> log for cloud_init_0.7.9-16test

Would it be possible to provide the full output of the boot process?

Comment 21 Vladimir 2017-11-16 15:48:59 UTC
Created attachment 1353586 [details]
/var/log for cloud-init-0.7.9-16test

Here is the whole /var/log folder
Or you can check this VM on the https://compute-ge-9.scl.lab.tlv.redhat.com/ovirt-engine/webadmin/?locale=en_US#vms
VM name is cloud_init_test

Comment 28 Israel Pinto 2017-12-20 11:32:06 UTC
(In reply to Vladimir from comment #26)
> Yes, this one works fine, hostname is set successfully

checked with: cloud-init-0.7.9-18.el7

moving to verify

Comment 29 John Boero 2018-02-06 16:48:05 UTC
Guys this is 9 months old.  Seriously?

Comment 30 Ryan McCabe 2018-02-06 17:36:21 UTC
(In reply to John Boero from comment #29)
> Guys this is 9 months old.  Seriously?

It's been fixed for months. If you need a package with a fix sooner than the RHEL 7.5 GA, please go through the regular support channels and let them know you need a z-stream.

Comment 31 Ryan McCabe 2018-02-06 17:38:43 UTC
If you're not a customer, I can post attach the patch here, but there's only so much engineering can do without somebody asking.

Comment 32 Ryan McCabe 2018-02-06 17:41:55 UTC
Created attachment 1392233 [details]
fix for the startup ordering

Comment 33 John Boero 2018-02-06 17:49:47 UTC
Thanks for clarifying. I don't see the cloud-init-0.7.9-18.el7 release anywhere (apparently as you said it's in EL Z).  This is also a current issue in Fedora 27 and even Rawhide (see below).  Any chance we can include Fedora and Fedora Atomic?

Thanks

  fedora27  ~  sudo dnf info cloud-init
Last metadata expiration check: 2:31:32 ago on Tue 06 Feb 2018 03:13:37 PM UTC.
Installed Packages
Name         : cloud-init
Version      : 0.7.9
Release      : 9.fc27
Arch         : noarch
Size         : 2.0 M
Source       : cloud-init-0.7.9-9.fc27.src.rpm
Repo         : @System
From repo    : anaconda
Summary      : Cloud instance init scripts
URL          : http://launchpad.net/cloud-init
License      : GPLv3
Description  : Cloud-init is a set of init scripts for cloud instances.  Cloud instances
             : need special scripts to run during initialization to retrieve and install
             : ssh keys and to let the user run various scripts.


  fedora27  ~  sudo dnf --releasever=rawhide info cloud-init
Last metadata expiration check: 8 days, 5:58:20 ago on Mon 29 Jan 2018 11:44:03 AM UTC.
Installed Packages
Name         : cloud-init
Version      : 0.7.9
Release      : 9.fc27
Arch         : noarch
Size         : 2.0 M
Source       : cloud-init-0.7.9-9.fc27.src.rpm
Repo         : @System
From repo    : anaconda
Summary      : Cloud instance init scripts
URL          : http://launchpad.net/cloud-init
License      : GPLv3
Description  : Cloud-init is a set of init scripts for cloud instances.  Cloud instances
             : need special scripts to run during initialization to retrieve and install
             : ssh keys and to let the user run various scripts.

Available Packages
Name         : cloud-init
Version      : 17.1
Release      : 1.fc28
Arch         : noarch
Size         : 823 k
Source       : cloud-init-17.1-1.fc28.src.rpm
Repo         : updates
Summary      : Cloud instance init scripts
URL          : http://launchpad.net/cloud-init
License      : ASL 2.0 or GPLv3
Description  : Cloud-init is a set of init scripts for cloud instances.  Cloud instances
             : need special scripts to run during initialization to retrieve and install
             : ssh keys and to let the user run various scripts.

Comment 34 John Boero 2018-02-06 17:51:27 UTC
Yes I have a subscription and access to Z-Stream repos but surprised it's not GA yet and surprised it's not hit Fedora yet.

Comment 35 Ryan McCabe 2018-02-06 17:54:37 UTC
Sure, I can work with the Fedora maintainer to get it fixed there. The build mentioned in the comments was an interim build that was only tested internally.

In general, we're only able to release a package with a fix between releases in RHEL if there's an associated customer who asks for a package with a fix sooner, and that request is approved -- it's kind out of our hands.

For Fedora, there's a lot less process involved, and getting a fix out shouldn't take long at all. Could you please file a bug against the Fedora package? You can clone this bug against the Fedora releases that are broken to save time.

Comment 36 John Boero 2018-02-06 18:00:05 UTC
OK excellent thanks Ryan.  I'll file that now.

Comment 38 gangadhar01a 2018-04-03 23:05:24 UTC
Hi,

I am having the same issue for CentOS 7 VM, any fix for this?

Comment 39 Ryan McCabe 2018-04-04 15:28:29 UTC
Created attachment 1417331 [details]
patch

Yes, the fix will be in the next release. I have attached the patch that fixes it if you don't want to wait.

Comment 40 gangadhar01a 2018-04-04 18:34:54 UTC
I have noticed the RHEV not using the cloud init pay load for CentOS machines VM. We are using the following version 


cloud-init.x86_64                                           0.7.9-9.el7


I will provide an update after I applied the patch. Hopefully this should work.

Comment 42 errata-xmlrpc 2018-04-10 14:05:07 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHEA-2018:0806

Comment 43 John Boero 2018-08-31 09:00:22 UTC
*** Bug 1542657 has been marked as a duplicate of this bug. ***


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