From ea6a2bfd95b65639676b9ccd7920a451d33fe610 Mon Sep 17 00:00:00 2001 From: Michael Scherer Date: Sun, 8 May 2016 11:33:54 +0200 Subject: [PATCH] Use type='path' rather than str, so path is expanded correctly --- lib/ansible/modules/extras/system/known_hosts.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/ansible/modules/extras/system/known_hosts.py b/lib/ansible/modules/extras/system/known_hosts.py index b68e85e0e77..b4c26e0efa5 100644 --- a/lib/ansible/modules/extras/system/known_hosts.py +++ b/lib/ansible/modules/extras/system/known_hosts.py @@ -85,9 +85,7 @@ def enforce_state(module, params): host = params["name"] key = params.get("key",None) port = params.get("port",None) - #expand the path parameter; otherwise module.add_path_info - #(called by exit_json) unhelpfully says the unexpanded path is absent. - path = os.path.expanduser(params.get("path")) + path = params.get("path") state = params.get("state") #Find the ssh-keygen binary sshkeygen = module.get_bin_path("ssh-keygen",True) @@ -240,7 +238,7 @@ def main(): argument_spec = dict( name = dict(required=True, type='str', aliases=['host']), key = dict(required=False, type='str'), - path = dict(default="~/.ssh/known_hosts", type='str'), + path = dict(default="~/.ssh/known_hosts", type='path'), state = dict(default='present', choices=['absent','present']), ), supports_check_mode = True