Bug 750979

Summary: cloud-init scripts do not make hostname changes permanent in /etc/sysconfig/network
Product: [Fedora] Fedora Reporter: Joseph W. Breu <joseph.breu>
Component: cloud-initAssignee: Garrett Holmstrom <gholms>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 16CC: gholms
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: cloud-init-0.6.3-0.1.bzr532.fc16 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-03-17 23:38:06 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Joseph W. Breu 2011-11-03 04:56:39 UTC
Description of problem:
cloud-init does not make the hostname ec2 metadata changes permanent in /etc/sysconfig/network.  Instead it follows the default behavior for Ubuntu and stores the hostname in /etc/hostname.

Version-Release number of selected component (if applicable):
cloud-init-0.6.2-0.7.bzr457.fc16.noarc

How reproducible:
every time

Steps to Reproduce:
1. yum install cloud-init
2. /usr/bin/cloud-init start
3. cat /etc/hostname ; cat /etc/sysconfig/network-scripts
  
Actual results:
/etc/hostname contains the hostname supplied via the ec2 metadata call http://169.254.169.254/latest/meta-data/hostname.  /etc/sysconfig/network is unchanged


Expected results:
I expect the hostname supplied by ec2 meta data to be stored in /etc/sysconfig/network and not /etc/hostname

Additional info:
/usr/lib/python2.7/site-packages/cloudinit/CloudConfig/cc_set_hostname.py

def set_hostanme is the culprit.  This needs to be changed to store
HOSTNAME=<data from ec2 metadata call>
in /etc/sysconfig/network

Sorry - I do not have a patch yet.

Comment 1 Garrett Holmstrom 2011-11-16 23:11:47 UTC
Storing a value in /etc/hostname is the correct method for persisting the hostname of a system that runs systemd, which consults /etc/sysconfig/network only as a fallback when /etc/hostname does not exist.

What problem are you trying to solve?  Are hostnames given in cloud-config not persisting properly?

Comment 2 Garrett Holmstrom 2012-03-05 22:28:50 UTC
The main cause of this problem seems to be a bug in systemd's transaction ordering that has since been fixed.  Since Fedora's EC2 image uses packages from the release without updates, this bug will still occur until a new image is created.

Even when that problem is fixed, however, there is another bug that may prevent this from working:  /usr/bin/cloud-init returns with the wrong code on EC2, which does not affect upstream's upstart tasks but *does* affect Fedora's systemd units.  This was recently fixed with code that should appear in the next update.  Sorry for the wait.

Comment 3 Fedora Update System 2012-03-05 22:40:13 UTC
cloud-init-0.6.3-0.1.bzr532.fc17 has been submitted as an update for Fedora 17.
https://admin.fedoraproject.org/updates/cloud-init-0.6.3-0.1.bzr532.fc17

Comment 4 Fedora Update System 2012-03-05 22:41:44 UTC
cloud-init-0.6.3-0.1.bzr532.fc16 has been submitted as an update for Fedora 16.
https://admin.fedoraproject.org/updates/cloud-init-0.6.3-0.1.bzr532.fc16

Comment 5 Fedora Update System 2012-03-08 04:53:47 UTC
Package cloud-init-0.6.3-0.1.bzr532.fc16:
* should fix your issue,
* was pushed to the Fedora 16 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing cloud-init-0.6.3-0.1.bzr532.fc16'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2012-3330/cloud-init-0.6.3-0.1.bzr532.fc16
then log in and leave karma (feedback).

Comment 6 Fedora Update System 2012-03-13 18:32:32 UTC
cloud-init-0.6.3-0.1.bzr532.fc17 has been pushed to the Fedora 17 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 7 Fedora Update System 2012-03-17 23:38:06 UTC
cloud-init-0.6.3-0.1.bzr532.fc16 has been pushed to the Fedora 16 stable repository.  If problems still persist, please make note of it in this bug report.