diff --git a/lib/ansible/module_utils/basic.py b/lib/ansible/module_utils/basic.py index d2e08f713dc..1aa63fee0f7 100644 --- a/lib/ansible/module_utils/basic.py +++ b/lib/ansible/module_utils/basic.py @@ -1017,6 +1017,9 @@ class AnsibleModule(object): msg = "Argument 'args' to run_command must be list or string" self.fail_json(rc=257, cmd=args, msg=msg) + # expand things like $HOME and ~ + args = [ os.path.expandvars(os.path.expanduser(x)) for x in args ] + rc = 0 msg = None st_in = None