ec2_vpc module not idempotent

17 views
Skip to first unread message

colin byrne

unread,
Oct 18, 2016, 6:15:38 PM10/18/16
to Ansible Project
this module does not seem to be idempotent. Here is the documentation: http://docs.ansible.com/ansible/ec2_vpc_module.html,  which seems to indicate that VPC's will NOT be created if a VPC already exists with equivalent resource_tags and cidr_block values. 

Unfortunately, as many times as I run this role, it will create a new VPC. 

Here is my usage: 
- name: create vpcs
  ec2_vpc:
    state: '{{ item.state }}'
    region: '{{ item.region }}'
    vpc_id: '{{ item.vpc_id }}'
    cidr_block: '{{ item.cidr_block }}'
    resource_tags: { "Name": "{{item.name}}" }
    subnets: '{{ item.subnets }}'
    internet_gateway: '{{ item.internet_gateway }}'
    route_tables:
      - subnets: '{{ item.route_tables.private_subnets.subnets }}'
        routes:
          - dest: '{{ item.route_tables.private_subnets.routes.dest }}'
            gw: '{{ item.route_tables.private_subnets.routes.gw }}'
      - subnets: '{{ item.route_tables.public_subnets.subnets }}'
        routes:
          - dest: '{{ item.route_tables.public_subnets.routes.dest }}'
            gw: '{{ item.route_tables.private_subnets.routes.gw }}'
  with_items: vpcs
  register: vpc

Thanks for any help/guidance. 
Reply all
Reply to author
Forward
0 new messages