diff --git a/lib/ansible/plugins/filter/win_basename.yml b/lib/ansible/plugins/filter/win_basename.yml index f89baa5a27d..3bf4c5621cf 100644 --- a/lib/ansible/plugins/filter/win_basename.yml +++ b/lib/ansible/plugins/filter/win_basename.yml @@ -5,6 +5,7 @@ DOCUMENTATION: short_description: Get a Windows path's base name description: - Returns the last name component of a Windows path, what is left in the string that is not 'win_dirname'. + - While specifying an UNC (Universal Naming Convention) path, please make sure the path conforms to the UNC path syntax. options: _input: description: A Windows path. @@ -16,7 +17,11 @@ DOCUMENTATION: EXAMPLES: | # To get the last name of a file Windows path, like 'foo.txt' out of 'C:\Users\asdf\foo.txt' - {{ mypath | win_basename }} + filename: "{{ mypath | win_basename }}" + + # Get basename from the UNC path in the form of '\\\\' + # like '\\server1\test\foo.txt' returns 'foo.txt' + filename: "{{ mypath | win_basename }}" RETURN: _value: diff --git a/lib/ansible/plugins/filter/win_dirname.yml b/lib/ansible/plugins/filter/win_dirname.yml index dbc85c7716c..5a2e3a72c3c 100644 --- a/lib/ansible/plugins/filter/win_dirname.yml +++ b/lib/ansible/plugins/filter/win_dirname.yml @@ -5,6 +5,7 @@ DOCUMENTATION: short_description: Get a Windows path's directory description: - Returns the directory component of a Windows path, what is left in the string that is not 'win_basename'. + - While specifying an UNC (Universal Naming Convention) path, please make sure the path conforms to the UNC path syntax. options: _input: description: A Windows path. @@ -18,6 +19,10 @@ EXAMPLES: | # To get the last name of a file Windows path, like 'C:\users\asdf' out of 'C:\Users\asdf\foo.txt' {{ mypath | win_dirname }} + # Get dirname from the UNC path in the form of '\\\\' + # like '\\server1\test\foo.txt' returns '\\\\server1\\test\\' + filename: "{{ mypath | win_dirname }}" + RETURN: _value: description: The directory from the Windows path provided.