From 319412b9fac28ae0a0ae059f44e668bc7d3bf857 Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Tue, 19 Jun 2012 18:07:47 -0700 Subject: More paths missed (durn), but now fixed. --- cloudinit/transforms/ssh.py | 4 +++- cloudinit/transforms/update_etc_hosts.py | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'cloudinit/transforms') diff --git a/cloudinit/transforms/ssh.py b/cloudinit/transforms/ssh.py index 33d4bb54..e5e99560 100644 --- a/cloudinit/transforms/ssh.py +++ b/cloudinit/transforms/ssh.py @@ -52,7 +52,8 @@ def handle(_name, cfg, cloud, log, _args): # remove the static keys from the pristine image if cfg.get("ssh_deletekeys", True): - for f in glob.glob("/etc/ssh/ssh_host_*key*"): + key_pth = cloud.paths.join(False, "/etc/ssh/", "ssh_host_*key*") + for f in glob.glob(key_pth): try: util.del_file(f) except: @@ -88,6 +89,7 @@ def handle(_name, cfg, cloud, log, _args): for keytype in genkeys: keyfile = '/etc/ssh/ssh_host_%s_key' % (keytype) keyfile = cloud.paths.join(False, keyfile) + util.ensure_dir(os.path.dirname(keyfile)) if not os.path.exists(keyfile): cmd = ['ssh-keygen', '-t', keytype, '-N', '', '-f', keyfile] try: diff --git a/cloudinit/transforms/update_etc_hosts.py b/cloudinit/transforms/update_etc_hosts.py index d0e56183..75615db1 100644 --- a/cloudinit/transforms/update_etc_hosts.py +++ b/cloudinit/transforms/update_etc_hosts.py @@ -42,7 +42,8 @@ def handle(name, cfg, cloud, log, _args): raise Exception(("No hosts template could be" " found for distro %s") % (distro_n)) - templater.render_to_file(tpl_fn_name, '/etc/hosts', + out_fn = cloud.paths.join(False, '/etc/hosts') + templater.render_to_file(tpl_fn_name, out_fn, {'hostname': hostname, 'fqdn': fqdn}) elif manage_hosts == "localhost": -- cgit v1.2.3