From 2bf7297bf399d293b48371ee525872d2b4c02e97 Mon Sep 17 00:00:00 2001 From: Tim Rupp Date: Thu, 30 Mar 2017 13:31:00 -0700 Subject: [PATCH] Removes expanduser in favor of type path (#21369) Removes the usage of expanduser in favor of the type 'path' for module options. Related to #12263 --- lib/ansible/modules/commands/expect.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/lib/ansible/modules/commands/expect.py b/lib/ansible/modules/commands/expect.py index 7d41bb249e..f68f6374ca 100644 --- a/lib/ansible/modules/commands/expect.py +++ b/lib/ansible/modules/commands/expect.py @@ -130,9 +130,9 @@ def main(): module = AnsibleModule( argument_spec=dict( command=dict(required=True), - chdir=dict(), - creates=dict(), - removes=dict(), + chdir=dict(type='path'), + creates=dict(type='path'), + removes=dict(type='path'), responses=dict(type='dict', required=True), timeout=dict(type='int', default=30), echo=dict(type='bool', default=False), @@ -163,18 +163,17 @@ def main(): module.fail_json(rc=256, msg="no command given") if chdir: - chdir = os.path.abspath(os.path.expanduser(chdir)) + chdir = os.path.abspath(chdir) os.chdir(chdir) if creates: # do not run the command if the line contains creates=filename # and the filename already exists. This allows idempotence # of command executions. - v = os.path.expanduser(creates) - if os.path.exists(v): + if os.path.exists(creates): module.exit_json( cmd=args, - stdout="skipped, since %s exists" % v, + stdout="skipped, since %s exists" % creates, changed=False, rc=0 ) @@ -183,11 +182,10 @@ def main(): # do not run the command if the line contains removes=filename # and the filename does not exist. This allows idempotence # of command executions. - v = os.path.expanduser(removes) - if not os.path.exists(v): + if not os.path.exists(removes): module.exit_json( cmd=args, - stdout="skipped, since %s does not exist" % v, + stdout="skipped, since %s does not exist" % removes, changed=False, rc=0 )