From 29d6313366b81c6fb80f6cb4142441f958e2d2d1 Mon Sep 17 00:00:00 2001 From: Shawn Siefkas Date: Thu, 8 Oct 2015 20:53:26 -0500 Subject: [PATCH] Handling dry run exception --- .../modules/extras/cloud/amazon/ec2_vpc_route_table.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/ansible/modules/extras/cloud/amazon/ec2_vpc_route_table.py b/lib/ansible/modules/extras/cloud/amazon/ec2_vpc_route_table.py index 9de7a85a14e..12b5b22fa59 100644 --- a/lib/ansible/modules/extras/cloud/amazon/ec2_vpc_route_table.py +++ b/lib/ansible/modules/extras/cloud/amazon/ec2_vpc_route_table.py @@ -496,13 +496,13 @@ def ensure_route_table_present(connection, module): # If no route table returned then create new route table if route_table is None: - if module.check_mode: - module.exit_json(changed=True) - try: - route_table = connection.create_route_table(vpc_id) + route_table = connection.create_route_table(vpc_id, module.check_mode) changed = True - except EC2ResponseError, e: + except EC2ResponseError as e: + if e.error_code == 'DryRunOperation': + module.exit_json(changed=True) + module.fail_json(msg=e.message) if routes is not None: