Commit 9ba8de02 by Feanil Patel

Add gateway info is a internet gateway is created.

parent 251704f1
......@@ -205,6 +205,17 @@ def get_vpc_info(vpc):
'state': vpc.state,
})
def get_igw_info(igw):
"""
Get info about the internet gateway.
"""
if igw is None:
return {}
return ({
'id': igw.id,
})
def find_vpc(module, vpc_conn, vpc_id=None, cidr=None):
"""
Finds a VPC that matches a specific id or cidr + tags
......@@ -497,6 +508,7 @@ def create_vpc(module, vpc_conn):
module.fail_json(msg='Unable to delete old route table {0}, error: {1}'.format(rt.id, e))
vpc_dict = get_vpc_info(vpc)
igw_dict = get_igw_info(igw)
created_vpc_id = vpc.id
returned_subnets = []
current_subnets = vpc_conn.get_all_subnets(filters={ 'vpc_id': vpc.id })
......@@ -509,7 +521,7 @@ def create_vpc(module, vpc_conn):
'id': sn.id,
})
return (vpc_dict, created_vpc_id, returned_subnets, changed)
return (vpc_dict, created_vpc_id, returned_subnets, igw_dict, changed)
def terminate_vpc(module, vpc_conn, vpc_id=None, cidr=None):
"""
......@@ -615,9 +627,9 @@ def main():
subnets_changed = None
elif module.params.get('state') == 'present':
# Changed is always set to true when provisioning a new VPC
(vpc_dict, new_vpc_id, subnets_changed, changed) = create_vpc(module, vpc_conn)
(vpc_dict, new_vpc_id, subnets_changed, igw_dict, changed) = create_vpc(module, vpc_conn)
module.exit_json(changed=changed, vpc_id=new_vpc_id, vpc=vpc_dict, subnets=subnets_changed)
module.exit_json(changed=changed, vpc_id=new_vpc_id, vpc=vpc_dict, igw=igw_dict, subnets=subnets_changed)
# import module snippets
from ansible.module_utils.basic import *
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment