dirname¶
Collection Note
This module is part of the ansible.builtin collection. To install the collection, use:
Added in versionhistorical.
Synopsis¶
- Returns the 'head' component of a path, basically everything that is not the 'basename'.
Parameters¶
| Parameter | Defaults / Choices | Comments |
|---|---|---|
| _input path required |
A path. |
Notes¶
Note
- The result of this filter is different from the Unix dirname program; where dirname for C(/foo/bar/) returns C(/foo), the dirname filter returns the full path (C(/foo/bar/)).
Examples¶
# To get the dir name of a file path, like '/etc/asdf' out of '/etc/asdf/foo.txt'.
{{ mypath | dirname }}
Return Values¶
| Key | Data Type | Description | Returned |
|---|---|---|---|
| _value | path | The directory portion of the original path. |
Authors¶
- Ansible Core Team