4e9b7b0
Index: trunk/cloudinit/distros/fedora.py
4e9b7b0
===================================================================
4e9b7b0
--- trunk.orig/cloudinit/distros/fedora.py
4e9b7b0
+++ trunk/cloudinit/distros/fedora.py
4e9b7b0
@@ -23,9 +23,23 @@
4e9b7b0
 from cloudinit.distros import rhel
4e9b7b0
 
4e9b7b0
 from cloudinit import log as logging
4e9b7b0
+from cloudinit import util
4e9b7b0
 
4e9b7b0
 LOG = logging.getLogger(__name__)
4e9b7b0
 
4e9b7b0
 
4e9b7b0
 class Distro(rhel.Distro):
4e9b7b0
     default_user = 'ec2-user'
4e9b7b0
+
4e9b7b0
+    def set_hostname(self, hostname):
4e9b7b0
+        # sysconfig-based (inherited from rhel.Distro)
4e9b7b0
+        sysconfig_fname = self._paths.join(False, '/etc/sysconfig/network')
4e9b7b0
+        self._write_hostname(hostname, '/etc/sysconfig/network')
4e9b7b0
+        # systemd-based
4e9b7b0
+        etc_fname = self._paths.join(False, '/etc/hostname')
4e9b7b0
+        util.write_file(etc_fname, str(hostname) + '\n', 0644)
4e9b7b0
+
4e9b7b0
+        if sysconfig_fname == '/etc/sysconfig/network':
4e9b7b0
+            # Only do this if we are running in non-adjusted root mode
4e9b7b0
+            LOG.debug('Setting hostname to %s', hostname)
4e9b7b0
+            util.subp(['hostname', hostname])
4e9b7b0
Index: trunk/templates/hosts.fedora.tmpl
4e9b7b0
===================================================================
4e9b7b0
--- /dev/null
4e9b7b0
+++ trunk/templates/hosts.fedora.tmpl
4e9b7b0
@@ -0,0 +1,23 @@
4e9b7b0
+#*
4e9b7b0
+    This file /etc/cloud/templates/hosts.fedora.tmpl is only utilized
4e9b7b0
+    if enabled in cloud-config.  Specifically, in order to enable it
4e9b7b0
+    you need to add the following to config:
4e9b7b0
+      manage_etc_hosts: True
4e9b7b0
+*#
4e9b7b0
+# Your system has configured 'manage_etc_hosts' as True.
4e9b7b0
+# As a result, if you wish for changes to this file to persist
4e9b7b0
+# then you will need to either
4e9b7b0
+# a.) make changes to the master file in /etc/cloud/templates/hosts.fedora.tmpl
4e9b7b0
+# b.) change or remove the value of 'manage_etc_hosts' in
4e9b7b0
+#     /etc/cloud/cloud.cfg or cloud-config from user-data
4e9b7b0
+# 
4e9b7b0
+# The following lines are desirable for IPv4 capable hosts
4e9b7b0
+127.0.0.1 ${fqdn} ${hostname}
4e9b7b0
+127.0.0.1 localhost.localdomain localhost
4e9b7b0
+127.0.0.1 localhost4.localdomain4 localhost4
4e9b7b0
+
4e9b7b0
+# The following lines are desirable for IPv6 capable hosts
4e9b7b0
+::1 ${fqdn} ${hostname}
4e9b7b0
+::1 localhost.localdomain localhost
4e9b7b0
+::1 localhost6.localdomain6 localhost6
4e9b7b0
+