diff --git a/cloud-init-0.7.0-fedora-hostname.patch b/cloud-init-0.7.0-fedora-hostname.patch new file mode 100644 index 0000000..77fe860 --- /dev/null +++ b/cloud-init-0.7.0-fedora-hostname.patch @@ -0,0 +1,56 @@ +Index: trunk/cloudinit/distros/fedora.py +=================================================================== +--- trunk.orig/cloudinit/distros/fedora.py ++++ trunk/cloudinit/distros/fedora.py +@@ -23,9 +23,23 @@ + from cloudinit.distros import rhel + + from cloudinit import log as logging ++from cloudinit import util + + LOG = logging.getLogger(__name__) + + + class Distro(rhel.Distro): + default_user = 'ec2-user' ++ ++ def set_hostname(self, hostname): ++ # sysconfig-based (inherited from rhel.Distro) ++ sysconfig_fname = self._paths.join(False, '/etc/sysconfig/network') ++ self._write_hostname(hostname, '/etc/sysconfig/network') ++ # systemd-based ++ etc_fname = self._paths.join(False, '/etc/hostname') ++ util.write_file(etc_fname, str(hostname) + '\n', 0644) ++ ++ if sysconfig_fname == '/etc/sysconfig/network': ++ # Only do this if we are running in non-adjusted root mode ++ LOG.debug('Setting hostname to %s', hostname) ++ util.subp(['hostname', hostname]) +Index: trunk/templates/hosts.fedora.tmpl +=================================================================== +--- /dev/null ++++ trunk/templates/hosts.fedora.tmpl +@@ -0,0 +1,23 @@ ++#* ++ This file /etc/cloud/templates/hosts.fedora.tmpl is only utilized ++ if enabled in cloud-config. Specifically, in order to enable it ++ you need to add the following to config: ++ manage_etc_hosts: True ++*# ++# Your system has configured 'manage_etc_hosts' as True. ++# As a result, if you wish for changes to this file to persist ++# then you will need to either ++# a.) make changes to the master file in /etc/cloud/templates/hosts.fedora.tmpl ++# b.) change or remove the value of 'manage_etc_hosts' in ++# /etc/cloud/cloud.cfg or cloud-config from user-data ++# ++# The following lines are desirable for IPv4 capable hosts ++127.0.0.1 ${fqdn} ${hostname} ++127.0.0.1 localhost.localdomain localhost ++127.0.0.1 localhost4.localdomain4 localhost4 ++ ++# The following lines are desirable for IPv6 capable hosts ++::1 ${fqdn} ${hostname} ++::1 localhost.localdomain localhost ++::1 localhost6.localdomain6 localhost6 ++ diff --git a/cloud-init-0.7.0-hostname-refactor.patch b/cloud-init-0.7.0-hostname-refactor.patch deleted file mode 100644 index f8789e1..0000000 --- a/cloud-init-0.7.0-hostname-refactor.patch +++ /dev/null @@ -1,223 +0,0 @@ -Index: trunk/cloudinit/distros/__init__.py -=================================================================== ---- trunk.orig/cloudinit/distros/__init__.py -+++ trunk/cloudinit/distros/__init__.py -@@ -48,6 +48,7 @@ class Distro(object): - __metaclass__ = abc.ABCMeta - default_user = None - default_user_groups = None -+ default_hostname_conf_file = '/etc/hostname' - - def __init__(self, name, cfg, paths): - self._paths = paths -@@ -95,14 +96,69 @@ class Distro(object): - def get_option(self, opt_name, default=None): - return self._cfg.get(opt_name, default) - -- @abc.abstractmethod - def set_hostname(self, hostname): -+ conf_file = self.get_option('hostname_conf_file', -+ default=self.default_hostname_conf_file) -+ out_fn = self._paths.join(False, conf_file) -+ self._write_hostname(hostname, out_fn) -+ if out_fn == conf_file: -+ # We only do this if we are running in non-adjusted root mode -+ LOG.debug("Setting hostname to %s", hostname) -+ util.subp(['hostname', hostname]) -+ -+ def update_hostname(self, hostname, prev_hostname_fn): -+ conf_file = self.get_option('hostname_conf_file', -+ default=self.default_hostname_conf_file) -+ hostname_prev = self._read_hostname(prev_hostname_fn) -+ read_fn = self._paths.join(True, conf_file) -+ hostname_in_conf = self._read_hostname(read_fn) -+ update_files = [] -+ if not hostname_prev or hostname_prev != hostname: -+ update_files.append(prev_hostname_fn) -+ if (not hostname_in_conf or -+ (hostname_in_conf == hostname_prev -+ and hostname_in_conf != hostname)): -+ write_fn = self._paths.join(False, conf_file) -+ update_files.append(write_fn) -+ for fn in update_files: -+ try: -+ self._write_hostname(hostname, fn) -+ except: -+ util.logexc(LOG, "Failed to write hostname %s to %s", -+ hostname, fn) -+ if (hostname_in_conf and hostname_prev and -+ hostname_in_conf != hostname_prev): -+ LOG.debug(("Hostname in %s differs from that in %s; assuming " -+ "hostname is user-maintained"), prev_hostname_fn, conf_file) -+ if conf_file in update_files: -+ # We only do this if we are running in non-adjusted root mode -+ LOG.debug("Setting hostname to %s", hostname) -+ util.subp(["hostname", hostname]) -+ -+ @abc.abstractmethod -+ def _write_hostname(self, hostname, filename): - raise NotImplementedError() - -+ def _write_bare_hostname(self, hostname, out_fn): -+ # "" gives trailing newline. -+ util.write_file(out_fn, "%s\n" % str(hostname), 0644) -+ - @abc.abstractmethod -- def update_hostname(self, hostname, prev_hostname_fn): -+ def _read_hostname(self, filename, default=None): - raise NotImplementedError() - -+ def _read_bare_hostname(self, filename, default=None): -+ contents = util.load_file(filename, quiet=True) -+ for line in contents.splitlines(): -+ c_pos = line.find("#") -+ # Handle inline comments -+ if c_pos != -1: -+ line = line[0:c_pos] -+ line_c = line.strip() -+ if line_c: -+ return line_c -+ return default -+ - @abc.abstractmethod - def package_command(self, cmd, args=None): - raise NotImplementedError() -Index: trunk/cloudinit/distros/debian.py -=================================================================== ---- trunk.orig/cloudinit/distros/debian.py -+++ trunk/cloudinit/distros/debian.py -@@ -57,56 +57,11 @@ class Distro(distros.Distro): - net_fn = self._paths.join(False, "/etc/network/interfaces") - util.write_file(net_fn, settings) - -- def set_hostname(self, hostname): -- out_fn = self._paths.join(False, "/etc/hostname") -- self._write_hostname(hostname, out_fn) -- if out_fn == '/etc/hostname': -- # Only do this if we are running in non-adjusted root mode -- LOG.debug("Setting hostname to %s", hostname) -- util.subp(['hostname', hostname]) -- - def _write_hostname(self, hostname, out_fn): -- # "" gives trailing newline. -- util.write_file(out_fn, "%s\n" % str(hostname), 0644) -- -- def update_hostname(self, hostname, prev_fn): -- hostname_prev = self._read_hostname(prev_fn) -- read_fn = self._paths.join(True, "/etc/hostname") -- hostname_in_etc = self._read_hostname(read_fn) -- update_files = [] -- if not hostname_prev or hostname_prev != hostname: -- update_files.append(prev_fn) -- if (not hostname_in_etc or -- (hostname_in_etc == hostname_prev and -- hostname_in_etc != hostname)): -- write_fn = self._paths.join(False, "/etc/hostname") -- update_files.append(write_fn) -- for fn in update_files: -- try: -- self._write_hostname(hostname, fn) -- except: -- util.logexc(LOG, "Failed to write hostname %s to %s", -- hostname, fn) -- if (hostname_in_etc and hostname_prev and -- hostname_in_etc != hostname_prev): -- LOG.debug(("%s differs from /etc/hostname." -- " Assuming user maintained hostname."), prev_fn) -- if "/etc/hostname" in update_files: -- # Only do this if we are running in non-adjusted root mode -- LOG.debug("Setting hostname to %s", hostname) -- util.subp(['hostname', hostname]) -+ return self._write_bare_hostname(hostname, out_fn) - - def _read_hostname(self, filename, default=None): -- contents = util.load_file(filename, quiet=True) -- for line in contents.splitlines(): -- c_pos = line.find("#") -- # Handle inline comments -- if c_pos != -1: -- line = line[0:c_pos] -- line_c = line.strip() -- if line_c: -- return line_c -- return default -+ return self._read_bare_hostname(filename, default=default) - - def _get_localhost_ip(self): - # Note: http://www.leonardoborda.com/blog/127-0-1-1-ubuntu-debian/ -Index: trunk/cloudinit/distros/fedora.py -=================================================================== ---- trunk.orig/cloudinit/distros/fedora.py -+++ trunk/cloudinit/distros/fedora.py -@@ -30,3 +30,10 @@ LOG = logging.getLogger(__name__) - class Distro(rhel.Distro): - distro_name = 'fedora' - default_user = 'ec2-user' -+ default_hostname_conf_file = '/etc/hostname' -+ -+ def _write_hostname(self, hostname, out_fn): -+ return self._write_bare_hostname(hostname, out_fn) -+ -+ def _read_hostname(self, filename, default=None): -+ return self._read_bare_hostname(filename, default=default) -Index: trunk/cloudinit/distros/rhel.py -=================================================================== ---- trunk.orig/cloudinit/distros/rhel.py -+++ trunk/cloudinit/distros/rhel.py -@@ -57,6 +57,7 @@ D_QUOTE_CHARS = { - - - class Distro(distros.Distro): -+ default_hostname_conf_file = '/etc/sysconfig/network' - - def __init__(self, name, cfg, paths): - distros.Distro.__init__(self, name, cfg, paths) -@@ -128,14 +129,6 @@ class Distro(distros.Distro): - if nameservers or searchservers: - self._write_resolve(nameservers, searchservers) - -- def set_hostname(self, hostname): -- out_fn = self._paths.join(False, '/etc/sysconfig/network') -- self._write_hostname(hostname, out_fn) -- if out_fn == '/etc/sysconfig/network': -- # Only do this if we are running in non-adjusted root mode -- LOG.debug("Setting hostname to %s", hostname) -- util.subp(['hostname', hostname]) -- - def apply_locale(self, locale, out_fn=None): - if not out_fn: - out_fn = self._paths.join(False, '/etc/sysconfig/i18n') -@@ -151,33 +144,6 @@ class Distro(distros.Distro): - w_contents = "\n".join(contents.write()) - util.write_file(out_fn, w_contents, 0644) - -- def update_hostname(self, hostname, prev_file): -- hostname_prev = self._read_hostname(prev_file) -- read_fn = self._paths.join(True, "/etc/sysconfig/network") -- hostname_in_sys = self._read_hostname(read_fn) -- update_files = [] -- if not hostname_prev or hostname_prev != hostname: -- update_files.append(prev_file) -- if (not hostname_in_sys or -- (hostname_in_sys == hostname_prev -- and hostname_in_sys != hostname)): -- write_fn = self._paths.join(False, "/etc/sysconfig/network") -- update_files.append(write_fn) -- for fn in update_files: -- try: -- self._write_hostname(hostname, fn) -- except: -- util.logexc(LOG, "Failed to write hostname %s to %s", -- hostname, fn) -- if (hostname_in_sys and hostname_prev and -- hostname_in_sys != hostname_prev): -- LOG.debug(("%s differs from /etc/sysconfig/network." -- " Assuming user maintained hostname."), prev_file) -- if "/etc/sysconfig/network" in update_files: -- # Only do this if we are running in non-adjusted root mode -- LOG.debug("Setting hostname to %s", hostname) -- util.subp(['hostname', hostname]) -- - def _read_hostname(self, filename, default=None): - (_exists, contents) = self._read_conf(filename) - if 'HOSTNAME' in contents: diff --git a/cloud-init-0.7.0-ssh-key-users.patch b/cloud-init-0.7.0-ssh-key-users.patch deleted file mode 100644 index db11b09..0000000 --- a/cloud-init-0.7.0-ssh-key-users.patch +++ /dev/null @@ -1,79 +0,0 @@ -Index: trunk/cloudinit/config/cc_ssh_authkey_fingerprints.py -=================================================================== ---- trunk.orig/cloudinit/config/cc_ssh_authkey_fingerprints.py -+++ trunk/cloudinit/config/cc_ssh_authkey_fingerprints.py -@@ -21,7 +21,8 @@ import hashlib - - from prettytable import PrettyTable - --from cloudinit import ssh_util -+from cloudinit.ssh_util import extract_authorized_keys as eak -+ - from cloudinit import util - - -@@ -40,8 +41,9 @@ def _gen_fingerprint(b64_text, hash_meth - hasher = hashlib.new(hash_meth) - hasher.update(base64.b64decode(b64_text)) - return ":".join(_split_hash(hasher.hexdigest())) -- except TypeError: -- # Raised when b64 not really b64... -+ except (TypeError, ValueError): -+ # Raised when b64 not really b64... or -+ # when the hash type isn't valid - return '?' - - -@@ -84,13 +86,48 @@ def _pprint_key_entries(user, key_fn, ke - stderr=False, console=True) - - -+def translate_user_name(uname, distro, log): -+ if not uname: -+ uname = '' -+ uname = uname.strip() -+ real_name = None -+ if uname.lower() == 'default': -+ try: -+ real_name = distro.get_default_user() -+ except NotImplementedError: -+ log.warn("Distro has not implemented default user " -+ "creation. No default user will be translated.") -+ else: -+ real_name = uname -+ return real_name -+ -+ - def handle(name, cfg, cloud, log, _args): - if 'no_ssh_fingerprints' in cfg: - log.debug(("Skipping module named %s, " - "logging of ssh fingerprints disabled"), name) -+ return -+ -+ if not 'users' in cfg: -+ log.debug(("Skipping module named %s, " -+ "logging of ssh fingerprints disabled " -+ "since no user/s provided"), name) -+ return -+ -+ users_to_hash = [] -+ for user_config in cfg['users']: -+ user_name = None -+ if isinstance(user_config, (basestring, str)): -+ user_name = translate_user_name(user_config, cloud.distro, log) -+ elif isinstance(user_config, (dict)): -+ if 'name' in user_config: -+ user_name = translate_user_name(user_config['name'], -+ cloud.distro, log) -+ if user_name: -+ users_to_hash.append(user_name) - -- user_name = util.get_cfg_option_str(cfg, "user", "ubuntu") - hash_meth = util.get_cfg_option_str(cfg, "authkey_hash", "md5") -- extract = ssh_util.extract_authorized_keys -- (auth_key_fn, auth_key_entries) = extract(user_name, cloud.paths) -- _pprint_key_entries(user_name, auth_key_fn, auth_key_entries, hash_meth) -+ for user_name in users_to_hash: -+ (auth_key_fn, auth_key_entries) = eak(user_name, cloud.paths) -+ _pprint_key_entries(user_name, auth_key_fn, -+ auth_key_entries, hash_meth) diff --git a/cloud-init-0.7.0-sudoers-perms.patch b/cloud-init-0.7.0-sudoers-perms.patch deleted file mode 100644 index ba1989a..0000000 --- a/cloud-init-0.7.0-sudoers-perms.patch +++ /dev/null @@ -1,13 +0,0 @@ -Index: trunk/cloudinit/distros/__init__.py -=================================================================== ---- trunk.orig/cloudinit/distros/__init__.py -+++ trunk/cloudinit/distros/__init__.py -@@ -395,7 +395,7 @@ class Distro(object): - content += "\n" - - if not os.path.exists(sudo_file): -- util.write_file(sudo_file, content, 0644) -+ util.write_file(sudo_file, content, 0440) - - else: - try: diff --git a/cloud-init.spec b/cloud-init.spec index cacc71c..a87bcfd 100644 --- a/cloud-init.spec +++ b/cloud-init.spec @@ -2,26 +2,18 @@ Name: cloud-init Version: 0.7.0 -Release: 0.3.bzr659%{?dist} +Release: 1%{?dist} Summary: Cloud instance init scripts Group: System Environment/Base License: GPLv3 URL: http://launchpad.net/cloud-init -# bzr export -r 659 cloud-init-0.7.0-bzr659.tar.gz lp:cloud-init -Source0: %{name}-%{version}-bzr659.tar.gz +Source0: https://launchpad.net/cloud-init/trunk/0.7.0/+download/cloud-init-0.7.0.tar.gz Source1: cloud-init-fedora.cfg Source2: cloud-init-README.fedora Patch0: cloud-init-0.7.0-fedora.patch -# Make Fedora use the same hostname-updating code as Debian (/etc/hostname) -# https://code.launchpad.net/~gholms/cloud-init/hostname-refactor/+merge/125869 -Patch1: cloud-init-0.7.0-hostname-refactor.patch -# Fix fingerprint printing caused by recent user code refactoring -# https://code.launchpad.net/~harlowja/cloud-init/patch-ssh-key-users/+merge/125606 -Patch2: cloud-init-0.7.0-ssh-key-users.patch -# Give sudoers 0440 permissions, not 0644 -# https://code.launchpad.net/~gholms/cloud-init/sudoers-perms/+merge/125873 -Patch3: cloud-init-0.7.0-sudoers-perms.patch +# Make Fedora update both /etc/hostname and /etc/sysconfig/network +Patch1: cloud-init-0.7.0-fedora-hostname.patch BuildArch: noarch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) @@ -56,11 +48,9 @@ ssh keys and to let the user run various scripts. %prep -%setup -q -n %{name}-%{version}-bzr659 +%setup -q -n %{name}-%{version} %patch0 -p1 %patch1 -p1 -%patch2 -p1 -%patch3 -p1 cp -p %{SOURCE2} README.fedora @@ -138,6 +128,9 @@ fi %changelog +* Tue Oct 9 2012 Garrett Holmstrom - 0.7.0-1 +- Rebased against version 0.7.0 + * Sat Sep 22 2012 Garrett Holmstrom - 0.7.0-0.3.bzr659 - Added dmidecode dependency for DataSourceAltCloud diff --git a/sources b/sources index 0cef7d2..dfd4b81 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -77321bda6dd15f21aab00d1c0cf28d67 cloud-init-0.7.0-bzr659.tar.gz +1b18e8dfd8789473d9f66cd87cc64a50 cloud-init-0.7.0.tar.gz