Passing a list of ressources to ansible

Hi,

I am creating multiple vms and the corresponding number of public ip with terraform.

I am also using a local-exec provisionner for ansible, and hoping to pass the list of public ips created to ansible and the jinja templating system via the extra-vars command line parameters. However, i am failing with this error message:

Error: Invalid template interpolation value: Cannot include the given value in a string template: string required.

This is what I pass as parameter:

–extra-vars ‘squids=${azurerm_public_ip.test.*.ip_address}’

How can i pass a dynamic list of all the ips created so I can jinja configure a template to deploy on the machine with ansible.

thanks

I got it to work with jsonencode as follows:

–extra-vars 'squids=${jsonencode(azurerm_public_ip.test.*.ip_address)}