diff --git a/lib/ansible/module_utils/basic.py b/lib/ansible/module_utils/basic.py index 1988857610..f47347482f 100644 --- a/lib/ansible/module_utils/basic.py +++ b/lib/ansible/module_utils/basic.py @@ -1069,7 +1069,7 @@ class AnsibleModule(object): if path_prefix: kwargs['env'] = env - if cwd: + if cwd and os.path.isdir(cwd): kwargs['cwd'] = cwd