I want to use with_nested to assemble a list by iterating over two lists and extracting particular keys from both -- ideally something like ...:
- name: "Build flat list of security group rules that should exist"
set_fact:
rulesList:
- proto: "{{ item.1.proto }}"
from_port: "{{ item.1.from_port }}"
to_port: "{{ item.1.to_port }}"
cidr_ip: "{{ item.0 }}"
with_nested:
- "{{ server_ips }}"
- "{{ webservice_security_rules }}"
I need to _build_ the list in advance so that I can pass the entire list into the ec2_group module -- as in:
ec2_group:
name: some_group
description: All security rules for some_group
vpc_id: some_vpc
region: some_region
aws_access_key: "{{encrypted_access_key}}"
aws_secret_key: "{{encrypted_secret_key}}"
rules: "{{rulesList}}"
NOTE: I cannot use with_nested as an argument to the ec2_group module, that would result in multiple task invocations -- but for idempotent behavior, I need to pass ALL the rules to ec2_group module in one invocation.
What's a good way to accomplish this?
On a side note: I can't understand why ansible seems to go so far out of its way to make this harder than it needs to be ... Ansible really seems to be sorely lacking in features that would make it easy to build up data-structures from other data-structures ...