eclipseansibledelete-directory

using ansible "win_file" module to remove a folder gives error saying path too long


I am using the win_file ansible module to remove a directory. However, when it runs the playbook, I am seeing the following error:

"msg": "Failed to delete C:\\product\\eclipse-cpp-2019-06-R-win32-x86_64\\eclipse\\plugins\\com.amazonaws.eclipse.elasticbeanstalk_1.0.0.v201807201743\\com\\amazonaws\\eclipse\\elasticbeanstalk\\server\\ui\\configEditor: The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters."

The Ansible playbook (uninstall.yml) is being run via UCD (UrbanCode Deploy). This is my ansible code:

- name: Remove install_home folder
win_file:
   path: "{{install_home}}"
   state: absent

Anyone have any thoughts on whether the above error is caused by an OS, Ansible, UCD or limitation. I'd appreciate any thoughts/guidance on how I may get past the above.

Many thanks


Solution

  • Its the limitation coming from the OS, as per this:

    In editions of Windows before Windows 10 version 1607, the maximum length for a path is MAX_PATH, which is defined as 260 characters. In later versions of Windows, changing a registry key or using the Group Policy tool is required to remove the limit. See Maximum Path Length Limitation for full details.

    To prevent this issue:

    To specify an extended-length path, use the "\\?\" prefix. For example, "\\?\D:\very long path".The maximum path of 32,767 characters is approximate, because the "\?" prefix may be expanded to a longer string by the system at run time, and this expansion applies to the total length.

    Eg:

    "\\?\C:\\product\\eclipse-cpp-2019-06-R-win32-x86_64\\eclipse\\plugins\\com.amazonaws.eclipse.elasticbeanstalk_1.0.0.v201807201743\\com\\amazonaws\\eclipse\\elasticbeanstalk\\server\\ui\\configEditor"