ansible.builtin.commonpath filter – gets the common path
Note
This filter plugin is part of ansible-core
and included in all Ansible
installations. In most cases, you can use the short
plugin name
commonpath
even without specifying the collections:
keyword.
However, we recommend you use the FQCN for easy linking to the
plugin documentation and to avoid conflicting with other collections that may have
the same filter plugin name.
New in ansible-core 2.15
Synopsis
Returns the longest common path from the given list of paths.
Input
This describes the input of the filter, the value before | ansible.builtin.commonpath
.
Parameter |
Comments |
---|---|
A list of paths. |
See Also
See also
- ansible.builtin.basename filter plugin
get a path’s base name.
Examples
# To get the longest common path (ex. '/foo/bar') from the given list of paths (ex. ['/foo/bar/foobar','/foo/bar'])
{{ listofpaths | commonpath }}
Return Value
Key |
Description |
---|---|
The longest common path from the given list of paths. Returned: success |