Struggling to make ec2_vpc Idempotent





down votefavorite


|


I am creating a VPC in AWS using Ansible. The following play is run



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



First time around this creates everything perfectly. Second time around, I expect it to not do anything as everything has been created, however, the public subnet is updated to a private one.



Why? What am I doing wrong?



Feel free to answer/help with this question here or on stackoverflow - http://stackoverflow.com/questions/35125292/cant-figure-out-why-subnet-is-being-updated


|

can you please check this, I hope it will help you.
https://github.com/arbabnazar/ansible-aws-roles/blob/master/roles/vpc/tasks/main.yml#L3