I am trying to create a play that defines by VPC infrastructure. I have a number of environments that are all set up in the same way but with different subnets. I'm trying to loop over a dict for each environment and then within that loop, loop to create by cidr subnets. However, it fails with an error "unsupported parameter for module: with_sequence".
I'm using the ipaddr custom filter.
I'm not sure quite how I would access my with_sequence item even if this did work. Would it be item[1]?
My play is below...
---
- name: VPC infrastructure
hosts: local
connection: local
gather_facts: false
vars:
environments:
prod:
vpc_cidr_block: 10.0.0.0/21
availability_zones: 2
android:
vpc_cidr_block: 10.0.8.0/21
availability_zones: 2
tasks:
- name: Create VPC
local_action:
module: ec2_vpc
state: present
region: "{{ aws_region }}"
cidr_block: "{{ item.value.vpc_cidr_block }}"
subnets:
- cidr: "{{ item.value.vpc_cidr_block | ipsubnet(24, 0) }}"
with_sequence: count={{ item.value.availability_zones }}
resource_tags: { "env": "{{ item.key }}" }
wait: yes
with_dict: environments
register: vpc
Any pointers appreciated.