ansible.builtin.split filter – split a string into a list
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
split.
However, we recommend you use the Fully Qualified Collection Name (FQCN) ansible.builtin.split 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-core 2.11
Synopsis
Using Python’s text object method
splitwe turn strings into lists via a ‘splitting character’.
Input
This describes the input of the filter, the value before | ansible.builtin.split.
Parameter |
Comments |
|---|---|
A string to split. |
Keyword parameters
This describes keyword parameters of the filter. These are the values key1=value1, key2=value2 and so on in the following
example: input | ansible.builtin.split(key1=value1, key2=value2, ...)
Parameter |
Comments |
|---|---|
The maximum number of splits to do. -1 means no limit. |
|
A string on which to split the original. |
Notes
Note
This is a passthrough to Python’s
str.split.
Examples
# listjojo => [ "jojo", "is", "a" ]
listjojo: "{{ 'jojo is a' | split }}"
# listjojocomma => [ "jojo is", " a" ]
listjojocomma: "{{ 'jojo is, a' | split(',') }}"
# listjojo_maxsplit => [ "jojo", "is a" ]
listjojo_maxsplit: "{{ 'jojo is a' | split(' ', 1) }}"
Return Value
Key |
Description |
|---|---|
List of substrings split from the original. Returned: success |