Merge pull request #2186 from mscherer/fix_know_host

Use type='path' rather than str, so path is expanded correctly
This commit is contained in:
René Moser 2016-05-08 12:13:16 +02:00
commit 23e6875430

View file

@ -85,9 +85,7 @@ def enforce_state(module, params):
host = params["name"] host = params["name"]
key = params.get("key",None) key = params.get("key",None)
port = params.get("port",None) port = params.get("port",None)
#expand the path parameter; otherwise module.add_path_info path = params.get("path")
#(called by exit_json) unhelpfully says the unexpanded path is absent.
path = os.path.expanduser(params.get("path"))
state = params.get("state") state = params.get("state")
#Find the ssh-keygen binary #Find the ssh-keygen binary
sshkeygen = module.get_bin_path("ssh-keygen",True) sshkeygen = module.get_bin_path("ssh-keygen",True)
@ -240,7 +238,7 @@ def main():
argument_spec = dict( argument_spec = dict(
name = dict(required=True, type='str', aliases=['host']), name = dict(required=True, type='str', aliases=['host']),
key = dict(required=False, type='str'), 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']), state = dict(default='present', choices=['absent','present']),
), ),
supports_check_mode = True supports_check_mode = True