community.routeros.list_to_dict filter – Convert a list of arguments to a dictionary
Note
This filter plugin is part of the community.routeros collection (version 2.19.0).
You might already have this collection installed if you are using the ansible
package.
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install community.routeros
.
To use it in a playbook, specify: community.routeros.list_to_dict
.
New in community.routeros 2.0.0
Synopsis
Convert a list of arguments to a dictionary.
Input
This describes the input of the filter, the value before | community.routeros.list_to_dict
.
Parameter |
Comments |
---|---|
A list of assignments. Can be the result of the community.routeros.split filter. |
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 | community.routeros.list_to_dict(key1=value1, key2=value2, ...)
Parameter |
Comments |
---|---|
Allows to accept arguments without values when set to Choices:
|
|
Allows to skip arguments whose value is empty when set to Choices:
|
Examples
- name: Convert a list to a dictionary
ansible.builtin.set_fact:
dictionary: "{{ ['foo=bar', 'comment=foo is bar'] | community.routeros.list_to_dict }}"
# dictionary == {'foo': 'bar', 'comment': 'foo is bar'}
Return Value
Key |
Description |
---|---|
A dictionary representation of the input data. Returned: success |