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.

New in Ansible 2.0

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

Input

string / 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 Value

Key

Description

Return value

list / elements=string

A list consisting of root of the path and the extension.

Returned: success

Authors

  • Matt Martz (@sivel)

Hint

Configuration entries for each entry type have a low to high priority order. For example, a variable that is lower in the list will override a variable that is higher up.