From 021ed9c960484dcb45941d48139ec86c2ce1f248 Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Fri, 10 Mar 2017 10:18:18 -0500 Subject: fix regression when no chpasswd/list was provided. This regression was caused by my rework of Sergio's branch. The change now still works when there is no chpasswd/list provided. --- cloudinit/config/cc_set_passwords.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/cloudinit/config/cc_set_passwords.py b/cloudinit/config/cc_set_passwords.py index fa343a7a..f36f7745 100755 --- a/cloudinit/config/cc_set_passwords.py +++ b/cloudinit/config/cc_set_passwords.py @@ -89,14 +89,15 @@ def handle(_name, cfg, cloud, log, args): if 'chpasswd' in cfg: chfg = cfg['chpasswd'] - if isinstance(chfg['list'], list): - log.debug("Handling input for chpasswd as list.") - plist = util.get_cfg_option_list(chfg, 'list', plist) - else: - log.debug("Handling input for chpasswd as multiline string.") - plist = util.get_cfg_option_str(chfg, 'list', plist) - if plist: - plist = plist.spitlines() + if 'list' in chfg and chfg['list']: + if isinstance(chfg['list'], list): + log.debug("Handling input for chpasswd as list.") + plist = util.get_cfg_option_list(chfg, 'list', plist) + else: + log.debug("Handling input for chpasswd as multiline string.") + plist = util.get_cfg_option_str(chfg, 'list', plist) + if plist: + plist = plist.splitlines() expire = util.get_cfg_option_bool(chfg, 'expire', expire) -- cgit v1.2.3