Ansible - create a list from variable

Hi,

I would like to create a list from parsing a variable that contains multiple ips separated by a comma.

The variable:

ips_input: “,1.1.1.1/32,2.2.2.2/32,3.3.3.3/32”

every item in the list should contain ip/mask.

the expected result:

ips_input_parsed: [
{
single_ip: “1.1.1.1/32”
}.

{
single_ip: “2.2.2.2/32”
}.

{
single_ip: “3.3.3.3/32”
}.

]

tried many different ways including regex_replace with no success.

please advise.

Thanks,
Morrissey

http://www.mydailytutorials.com/how-to-split-strings-and-join-them-in-a%E2%80%8Bnsibl%E2%80%8Be/

If your IP addresses are separated only by commas, and the comma-delimited strings contain only IP addresses, split() will do the job nicely. If there are things other than IP addresses in the input string, or if (as in your example string) you have empty strings, you will need to sanity-check the output from split().

Regards, K.