First, I really appreciate Ansible. Unfortunately, I'm having trouble using resource_tags with the ec2_vpc module. In the 1.9.4, installed with yum, the resource_tags are working well with subnets and the vpc but not for route tables. When I execute the following playbook in 1.9.4 everything is created perfectly except there's no resource tags on the route tables as specified below.
---
- hosts: localhost
vars:
region: us-west-2
vpc_name: Integration Environment VPC
environment_name: Integration
dmz1_id: nat-0e2cb00629ddcdfae
dmz2_id: nat-066c49781597d10a3
connection: local
gather_facts: False
tasks:
- name: "Create the {{ environment_name }} environment VPC"
ec2_vpc:
state: present
internet_gateway: yes
resource_tags: '{ "Name": "{{ vpc_name }}", "Environment": "{{ environment_name }}" }'
region: "{{ region }}"
subnets:
- cidr: "{{ tools_cidr }}"
az: us-west-2a
resource_tags: '{ "Name": "Tools Subnet", "Environment": "{{ environment_name }}" }'
- cidr: "{{ apptier1_cidr }}"
az: us-west-2a
resource_tags: '{ "Name": "Application Tier Subnet 1", "Environment": "{{ environment_name }}" }'
- cidr: "{{ apptier2_cidr }}"
az: us-west-2b
resource_tags: '{ "Name": "Application Tier Subnet 2", "Environment": "{{ environment_name }}" }'
- cidr: "{{ dmz1_cidr }}"
az: us-west-2a
resource_tags: '{ "Name": "DMZ Subnet 1", "Environment": "{{ environment_name }}" }'
- cidr: "{{ dmz2_cidr }}"
az: us-west-2b
resource_tags: '{ "Name": "DMZ Subnet 2", "Environment": "{{ environment_name }}" }'
- cidr: "{{ db1_cidr }}"
az: us-west-2a
resource_tags: '{ "Name": "DB Subnet 1", "Environment": "{{ environment_name }}" }'
- cidr: "{{ db2_cidr }}"
az: us-west-2b
resource_tags: '{ "Name": "DB Subnet 2", "Environment": "{{ environment_name }}" }'
route_tables:
- subnets:
- "{{ tools_cidr }}"
- "{{ dmz1_cidr }}"
- "{{ dmz2_cidr }}"
- "{{ db1_cidr }}"
- "{{ db2_cidr }}"
routes:
gw: igw
resource_tags: '{ "Name": "Default Internal Route", "Environment": "{{ environment_name }}" }'
- subnets:
- "{{ apptier1_cidr }}"
routes:
gw: "{{ dmz1_id }}"
resource_tags: '{ "Name": "DMZ1 Route", "Environment": "{{ environment_name }}" }'
- subnets:
- "{{ apptier2_cidr }}"
routes:
gw: "{{ dmz2_id }}"
resource_tags: '{ "Name": "DMZ2 Route", "Environment": "{{ environment_name }}" }'
I attempted to upgrade to the latest - version 2.1.0 - in the hopes that this might be a bug or missing feature that was solved recently. This same playbook cannot even execute, and fails with the message below:
/root/ansible/bin/ansible-playbook --private-key ~/.ssh/test.pub /root/infrastructure/ansible/environment_playbooks/01_create_vpc_subnets_and_routes.yml
PLAY ***************************************************************************
TASK [Create the Integration environment VPC] **********************************
fatal: [127.0.0.1]: FAILED! => {"changed": false, "failed": true, "msg": "unsupported parameter for module: resource_tags"}
NO MORE HOSTS LEFT *************************************************************
PLAY RECAP *********************************************************************
127.0.0.1 : ok=0 changed=0 unreachable=0 failed=1
Does anyone know if I'm doing something wrong or how I might get this to work in some version of Ansible?