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
split
we 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. |
Positional parameters
This describes positional parameters of the filter. These are the values positional1
, positional2
and so on in the following
example: input | ansible.builtin.split(positional1, positional2, ...)
Parameter |
Comments |
---|---|
A string on which to split the original. Default: |
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(',') }}"
Return Value
Key |
Description |
---|---|
List of substrings split from the original. Returned: success |
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.