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:
parent
738296e97f
commit
f796154dad
@ -37,10 +37,11 @@ def handle(name, cfg, cloud, log, _args):
|
|||||||
|
|
||||||
# Render from a template file
|
# Render from a template file
|
||||||
tpl_fn_name = cloud.get_template_filename("hosts.%s" %
|
tpl_fn_name = cloud.get_template_filename("hosts.%s" %
|
||||||
(cloud.distro.name))
|
(cloud.distro.osfamily))
|
||||||
if not tpl_fn_name:
|
if not tpl_fn_name:
|
||||||
raise RuntimeError(("No hosts template could be"
|
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',
|
templater.render_to_file(tpl_fn_name, '/etc/hosts',
|
||||||
{'hostname': hostname, 'fqdn': fqdn})
|
{'hostname': hostname, 'fqdn': fqdn})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user