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
.
However, we recommend you use the Fully Qualified Collection Name (FQCN) ansible.builtin.commonpath
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 (for example - '/foo/bar') from the given list of paths
# (for example - ['/foo/bar/foobar','/foo/bar'])
{{ listofpaths | commonpath }}
Return Value
Key |
Description |
---|---|
The longest common path from the given list of paths. Returned: success |