Fix broken cc_update_etc_hosts (LP: #1100036)

Right now, all distros but ubuntu will fail to manage /etc/hosts. This
is due to the fact that the templates are named:
- hosts.ubuntu.tmpl
- hosts.redhat.tmpl

The config handler is specifically looking for a template with the
given distro name.

This change addresses this issue and is contingent upon support of
'osfamilies' as implemented in LP: #1100029
(lp:~craigtracey/cloud-init/osfamilies)
This commit is contained in:
ctracey 2013-01-15 16:34:51 -05:00
parent 738296e97f
commit f796154dad
2 changed files with 3 additions and 2 deletions

View File

@ -37,10 +37,11 @@ def handle(name, cfg, cloud, log, _args):
# Render from a template file
tpl_fn_name = cloud.get_template_filename("hosts.%s" %
(cloud.distro.name))
(cloud.distro.osfamily))
if not tpl_fn_name:
raise RuntimeError(("No hosts template could be"
" found for distro %s") % (cloud.distro.name))
" found for distro %s") %
(cloud.distro.osfamily))
templater.render_to_file(tpl_fn_name, '/etc/hosts',
{'hostname': hostname, 'fqdn': fqdn})