ansible.builtin.splitext filter – split a path into root and file extension
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
splitext
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 a list of two, with the elements consisting of filename root and extension.
Input
This describes the input of the filter, the value before | ansible.builtin.splitext
.
Parameter |
Comments |
---|---|
A path. |
Examples
# gobble => [ '/etc/make', 'conf' ]
gobble: "{{ '/etc/make.conf' | splitext }}"
# file_n_ext => [ 'ansible', 'cfg' ]
file_n_ext: "{{ 'ansible.cfg' | splitext }}"
# hoax => ['/etc/hoasdf', '']
hoax: '{{ "/etc//hoasdf/"|splitext }}'
Return Value
Key |
Description |
---|---|
A list consisting of root of the path and the extension. Returned: success |