ansible.builtin.dirname filter – get a path’s directory name
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
dirname
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.
Synopsis
Returns the ‘head’ component of a path, basically everything that is not the ‘basename’.
Input
This describes the input of the filter, the value before | ansible.builtin.dirname
.
Parameter |
Comments |
---|---|
A path. |
See Also
See also
- ansible.builtin.basename filter plugin
The official documentation on the ansible.builtin.basename filter plugin.
Examples
# To get the dir name of a file path, like '/etc/asdf' out of '/etc/asdf/foo.txt'
{{ mypath | dirname }}
Return Value
Key |
Description |
---|---|
The directory portion of the original path. Returned: success |