Repository: ansible/ansible

Issue:
tags are empty on ec2_vpc_route_table creation
##### ISSUE TYPE
 - Bug Report

##### COMPONENT NAME
ec2_vpc_route_table

##### ANSIBLE VERSION
`2.3`

##### SUMMARY
From @jimrazmus on 2016-01-15T22:59:46Z
On the latest devel branch, I consistently see an empty tags field in a new route table's registered variable.  e.g.

changed: [localhost] => {"changed": true, "invocation": {"module_args": {"_ansible_check_mode": false, "_ansible_debug": false, "_ansible_diff": false, "_ansible_no_log": false, "_ansible_verbosity": 3, "aws_access_key": null, "aws_secret_key": null, "ec2_url": null, "lookup": "tag", "profile": null, "propagating_vgw_ids": null, "region": "us-east-1", "route_table_id": null, "routes": [{"destination_cidr_block": "0.0.0.0/0", "gateway_id": "igw-abe225cf"}], "security_token": null, "state": "present", "subnets": ["10.20.1.0/24", "10.20.2.0/24", "10.20.3.0/24", "10.20.4.0/24"], **"tags": {"Name": "dev_public_rtbl", "environment": "dev"}**, "validate_certs": true, "vpc_id": "vpc-c88af7ac"}, "module_name": "ec2_vpc_route_table"}, "route_table": {"id": "rtb-ca291bae", "routes": [{"destination_cidr_block": "10.20.0.0/16", "gateway_id": "local", "instance_id": null, "interface_id": null, "state": "active", "vpc_peering_connection_id": null}], **"tags": {}**, "vpc_id": "vpc-c88af7ac"}}

On the second and subsequent runs, the tags field is populated.  e.g.

ok: [localhost] => {"changed": false, "invocation": {"module_args": {"_ansible_check_mode": false, "_ansible_debug": false, "_ansible_diff": false, "_ansible_no_log": false, "_ansible_verbosity": 3, "aws_access_key": null, "aws_secret_key": null, "ec2_url": null, "lookup": "tag", "profile": null, "propagating_vgw_ids": null, "region": "us-east-1", "route_table_id": null, "routes": [{"destination_cidr_block": "0.0.0.0/0", "gateway_id": "igw-abe225cf"}], "security_token": null, "state": "present", "subnets": ["10.20.1.0/24", "10.20.2.0/24", "10.20.3.0/24", "10.20.4.0/24"], **"tags": {"Name": "dev_public_rtbl", "environment": "dev"}**, "validate_certs": true, "vpc_id": "vpc-c88af7ac"}, "module_name": "ec2_vpc_route_table"}, "route_table": {"id": "rtb-ca291bae", "routes": [{"destination_cidr_block": "10.20.0.0/16", "gateway_id": "local", "instance_id": null, "interface_id": null, "state": "active", "vpc_peering_connection_id": null}, {"destination_cidr_block": "0.0.0.0/0", "gateway_id": "igw-abe225cf", "instance_id": null, "interface_id": null, "state": "active", "vpc_peering_connection_id": null}], **"tags": {"Name": "dev_public_rtbl", "environment": "dev"}**, "vpc_id": "vpc-c88af7ac"}}

Copied from original issue: ansible/ansible-modules-extras#1506

tags are empty on ec2_vpc_route_table creation
##### ISSUE TYPE
 - Bug Report

##### COMPONENT NAME
ec2_vpc_route_table

##### ANSIBLE VERSION
`2.3`

##### SUMMARY
From @jimrazmus on 2016-01-15T22:59:46Z
On the latest devel branch, I consistently see an empty tags field in a new route table's registered variable.  e.g.

changed: [localhost] => {"changed": true, "invocation": {"module_args": {"_ansible_check_mode": false, "_ansible_debug": false, "_ansible_diff": false, "_ansible_no_log": false, "_ansible_verbosity": 3, "aws_access_key": null, "aws_secret_key": null, "ec2_url": null, "lookup": "tag", "profile": null, "propagating_vgw_ids": null, "region": "us-east-1", "route_table_id": null, "routes": [{"destination_cidr_block": "0.0.0.0/0", "gateway_id": "igw-abe225cf"}], "security_token": null, "state": "present", "subnets": ["10.20.1.0/24", "10.20.2.0/24", "10.20.3.0/24", "10.20.4.0/24"], **"tags": {"Name": "dev_public_rtbl", "environment": "dev"}**, "validate_certs": true, "vpc_id": "vpc-c88af7ac"}, "module_name": "ec2_vpc_route_table"}, "route_table": {"id": "rtb-ca291bae", "routes": [{"destination_cidr_block": "10.20.0.0/16", "gateway_id": "local", "instance_id": null, "interface_id": null, "state": "active", "vpc_peering_connection_id": null}], **"tags": {}**, "vpc_id": "vpc-c88af7ac"}}

On the second and subsequent runs, the tags field is populated.  e.g.

ok: [localhost] => {"changed": false, "invocation": {"module_args": {"_ansible_check_mode": false, "_ansible_debug": false, "_ansible_diff": false, "_ansible_no_log": false, "_ansible_verbosity": 3, "aws_access_key": null, "aws_secret_key": null, "ec2_url": null, "lookup": "tag", "profile": null, "propagating_vgw_ids": null, "region": "us-east-1", "route_table_id": null, "routes": [{"destination_cidr_block": "0.0.0.0/0", "gateway_id": "igw-abe225cf"}], "security_token": null, "state": "present", "subnets": ["10.20.1.0/24", "10.20.2.0/24", "10.20.3.0/24", "10.20.4.0/24"], **"tags": {"Name": "dev_public_rtbl", "environment": "dev"}**, "validate_certs": true, "vpc_id": "vpc-c88af7ac"}, "module_name": "ec2_vpc_route_table"}, "route_table": {"id": "rtb-ca291bae", "routes": [{"destination_cidr_block": "10.20.0.0/16", "gateway_id": "local", "instance_id": null, "interface_id": null, "state": "active", "vpc_peering_connection_id": null}, {"destination_cidr_block": "0.0.0.0/0", "gateway_id": "igw-abe225cf", "instance_id": null, "interface_id": null, "state": "active", "vpc_peering_connection_id": null}], **"tags": {"Name": "dev_public_rtbl", "environment": "dev"}**, "vpc_id": "vpc-c88af7ac"}}

Copied from original issue: ansible/ansible-modules-extras#1506



Discussion:

Resolving patch:
diff --git a/lib/ansible/modules/cloud/amazon/ec2_vpc_route_table.py b/lib/ansible/modules/cloud/amazon/ec2_vpc_route_table.py
--- a/lib/ansible/modules/cloud/amazon/ec2_vpc_route_table.py
+++ b/lib/ansible/modules/cloud/amazon/ec2_vpc_route_table.py
@@ -589,6 +589,7 @@ def ensure_route_table_present(connection, module):
     if not tags_valid and tags is not None:
         result = ensure_tags(connection, route_table.id, tags,
                              add_only=True, check_mode=module.check_mode)
+        route_table.tags = result['tags']
         changed = changed or result['changed']
 
     if subnets:


Test patch: