I can not understand why the subnet is being updated

I am creating a VPC in AWS using Ansible. The next playback is in progress.

- name: create vpc with multi-az subnets ec2_vpc: region: "{{ region }}" cidr_block: "{{ vpc_cidr_block }}" resource_tags: '{"Name":"{{ prefix }}_vpc"}' subnets: - cidr: "{{ vpc_cidr_subnet_public_0 }}" az: "{{ region }}{{ availability_zone_0 }}" resource_tags: '{"Name":"{{ prefix }}_subnet_public_0", "Class":"web", "Partner":prefix }' - cidr: "{{ vpc_cidr_subnet_private_0 }}" az: "{{ region }}{{ availability_zone_0 }}" resource_tags: '{"Name":"{{ prefix }}_subnet_private_0", "Class":"db", "Partner":prefix }' - cidr: "{{ vpc_cidr_subnet_private_1 }}" az: "{{ region }}{{ availability_zone_1 }}" resource_tags: '{"Name":"{{ prefix }}_subnet_private_1", "Class":"db", "Partner":prefix }' internet_gateway: yes route_tables: - subnets: - "{{ vpc_cidr_subnet_public_0 }}" routes: - dest: 0.0.0.0/0 gw: igw wait: yes register: vpc 

The first time this creates everything perfectly. The second time, I expect it to do nothing, since everything has been created, but the public subnet has been updated to private.

Why? What am I doing wrong?

[UPDATE]

Here are the variables:

 --- region: eu-west-1 prefix: staging vpc_environment: staging vpc_cidr_block: 20.0.0.0/16 vpc_cidr_subnet_public_0: 20.0.0.0/24 vpc_cidr_subnet_private_0: 20.0.1.0/24 vpc_cidr_subnet_private_1: 20.0.2.0/24 availability_zone_0: b availability_zone_1: c 

It’s also easy to clarify what’s going on. All resource tags of one subnet (public) are overwritten using tags of another subnet (private).

+8
amazon-web-services ansible
source share
1 answer

This is caused by the ansible-modules-core error in master - ec2_vpc . I registered an error and created

+2
source share

All Articles