diff --git a/lib/ansible/utils/path.py b/lib/ansible/utils/path.py index dc1155183a..3d9b35f970 100644 --- a/lib/ansible/utils/path.py +++ b/lib/ansible/utils/path.py @@ -22,7 +22,7 @@ from errno import EEXIST from ansible.errors import AnsibleError from ansible.utils.unicode import to_bytes, to_str -__all__ = ['unfrackpath'] +__all__ = ['unfrackpath', 'makedirs_safe'] def unfrackpath(path): ''' @@ -35,12 +35,14 @@ def unfrackpath(path): def makedirs_safe(path, mode=None): '''Safe way to create dirs in muliprocess/thread environments''' - if not os.path.exists(to_bytes(path, errors='strict')): + + rpath = unfrackpath(path) + if not os.path.exists(to_bytes(rpath, errors='strict')): try: if mode: - os.makedirs(path, mode) + os.makedirs(rpath, mode) else: - os.makedirs(path) + os.makedirs(rpath) except OSError as e: if e.errno != EEXIST: - raise AnsibleError("Unable to create local directories(%s): %s" % (path, to_str(e))) + raise AnsibleError("Unable to create local directories(%s): %s" % (rpath, to_str(e)))