Skip to content

split

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.11.

Synopsis

  • Using Python's text object method C(split) we turn strings into lists via a 'splitting character'.

Parameters

Parameter Defaults / Choices Comments
_input
str
required
A string to split.
_split_string
str
Default:
A string on which to split the original.

Notes

Note

  • This is a passthrough to Python's C(str.split).

Examples

# listjojo => [ "jojo", "is", "a" ]
listjojo: "{{ 'jojo is a' | split }}"

# listjojocomma => [ "jojo is", " a" ]
listjojocomma: "{{ 'jojo is, a' | split(',') }}"

Return Values

Key Data Type Description Returned
_value list List of substrings split from the original.