'Iterating over two lists in ansible

I'm new at Ansible and YAML syntax and I'm facing a simple issue: how to iterate over two lists, with the same index?

Something like that:

int[] listOne;
int[] listTwo;

---  Attribute some values to the lists  ----

for(int i = 0; i < 10; i++){
  int result = listOne[i] + listTwo[i];
}

In my case, I'm trying to attribute some values to route53 module, and they are in different lists.

Is there anyway to do it? I just found loops that iterate over a single list or nested lists.



Solution 1:[1]

UPDATE: Use loop command

[DEPRECATED]

Making a better search in Ansible's documentation, I found with_together module (see in docs), that does exactly what I was looking for.

It's important to look carefully at documentation :)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1