Skip to content

splitext

Collection Note

This module is part of the ansible.builtin collection. To install the collection, use:

ansible-galaxy collection install ansible.builtin
Added in version 2.0.

Synopsis

  • Returns a list of two, with the elements consisting of filename root and extension.

Parameters

Parameter Defaults / Choices Comments
_input
str
required
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 Values

Key Data Type Description Returned
_value list A list consisting of root of the path and the extension.

Authors

  • Matt Martz (@sivel)