diff --git a/lib/ansible/modules/system/authorized_key.py b/lib/ansible/modules/system/authorized_key.py index ab8440a892..f758eeb940 100644 --- a/lib/ansible/modules/system/authorized_key.py +++ b/lib/ansible/modules/system/authorized_key.py @@ -169,7 +169,7 @@ class keydict(dict): def __iter__(self): return iter(self.itemlist) def keys(self): - return self.itemlist + return list(set(self.itemlist)) def values(self): return [self[key] for key in self] def itervalues(self): @@ -254,7 +254,13 @@ def parseoptions(module, options): for part in parts: if "=" in part: (key, value) = part.split("=", 1) - options_dict[key] = value + if options_dict.has_key(key): + if isinstance(options_dict[key], list): + options_dict[key].append(value) + else: + options_dict[key] = [options_dict[key], value] + else: + options_dict[key] = value elif part != ",": options_dict[part] = None except: @@ -348,10 +354,13 @@ def writekeys(module, filename, keys): option_strings = [] for option_key in options.keys(): if options[option_key]: - option_strings.append("%s=%s" % (option_key, options[option_key])) + if isinstance(options[option_key], list): + for value in options[option_key]: + option_strings.append("%s=%s" % (option_key, value)) + else: + option_strings.append("%s=%s" % (option_key, options[option_key])) else: option_strings.append("%s" % option_key) - option_str = ",".join(option_strings) option_str += " " key_line = "%s%s %s %s\n" % (option_str, type, keyhash, comment)