Ansible version 2.3.0.0
I want to create two hosted zones 1 private and 1 public. When I create it manually on AWS console it gets created and the private hosted zone is associated with my VPC. However through Ansible only 1 zone is created. If the task to create private hosted zone is first then the private hosted zone is created and public is not created. The ID’s for both zone is returned as identical. If the task for public hosted zone is first then only the public hosted zone gets created and identical IDs are returned. I really don’t understand why it is having like this. No errors are thrown.
Script for creating vpc:
---
- name: Create VPC
ec2_vpc:
state: present
dns_hostnames: yes
dns_support: yes
cidr_block: "{{ vpc_ip_range }}"
resource_tags: "{{ vpc_resource_tags }}"
subnets:
- cidr: "{{ vpc_subnet_app_ip_range }}"
az: "{{ vpc_subnet_app_az }}"
resource_tags: "{{ vpc_subnet_app_resource_tags }}"
- cidr: "{{ vpc_subnet_db_ip_range }}"
az: "{{ vpc_subnet_db_az }}"
resource_tags: "{{ vpc_subnet_db_resource_tags }}"
- cidr: "{{ vpc_subnet_private_ip_range }}"
az: "{{ vpc_subnet_private_az }}"
resource_tags: "{{ vpc_subnet_private_resource_tags }}"
internet_gateway: True
route_tables:
- subnets:
- "{{ vpc_subnet_app_ip_range }}"
- "{{ vpc_subnet_db_ip_range }}"
- "{{ vpc_subnet_private_ip_range }}"
routes:
- dest: 0.0.0.0/0
gw: igw
region: "{{ vpc_region }}"
register: vpc
- name: Set VPC ID in a variable
set_fact:
vpc_id: "{{ vpc.vpc_id }}"
- name: Print VPC variable
debug:
msg: "{{ vpc_id }}"
Script for Creating Hosted Zones: