Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
configuration
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
configuration
Commits
a69ca469
Commit
a69ca469
authored
May 15, 2015
by
Feanil Patel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add updates to be able to get the internet gateway id as output.
parent
8719616c
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
3 deletions
+20
-3
playbooks/library/ec2_vpc_local
+20
-3
No files found.
playbooks/library/ec2_vpc_local
View file @
a69ca469
...
@@ -14,6 +14,10 @@
...
@@ -14,6 +14,10 @@
# You should have received a copy of the GNU General Public License
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
# Taken from version: 1.9 - PR to push up the changes here:
# https://github.com/ansible/ansible-modules-core/pull/1323
DOCUMENTATION
=
'''
DOCUMENTATION
=
'''
---
---
module: ec2_vpc
module: ec2_vpc
...
@@ -182,6 +186,17 @@ def get_vpc_info(vpc):
...
@@ -182,6 +186,17 @@ def get_vpc_info(vpc):
'state'
:
vpc
.
state
,
'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
):
def
find_vpc
(
module
,
vpc_conn
,
vpc_id
=
None
,
cidr
=
None
):
"""
"""
Finds a VPC that matches a specific id or cidr + tags
Finds a VPC that matches a specific id or cidr + tags
...
@@ -570,6 +585,7 @@ def create_vpc(module, vpc_conn):
...
@@ -570,6 +585,7 @@ def create_vpc(module, vpc_conn):
module
.
fail_json
(
msg
=
'Unable to delete old route table {0}, error: {1}'
.
format
(
rt
.
id
,
e
))
module
.
fail_json
(
msg
=
'Unable to delete old route table {0}, error: {1}'
.
format
(
rt
.
id
,
e
))
vpc_dict
=
get_vpc_info
(
vpc
)
vpc_dict
=
get_vpc_info
(
vpc
)
igw_dict
=
get_igw_info
(
igw
)
created_vpc_id
=
vpc
.
id
created_vpc_id
=
vpc
.
id
returned_subnets
=
[]
returned_subnets
=
[]
current_subnets
=
vpc_conn
.
get_all_subnets
(
filters
=
{
'vpc_id'
:
vpc
.
id
})
current_subnets
=
vpc_conn
.
get_all_subnets
(
filters
=
{
'vpc_id'
:
vpc
.
id
})
...
@@ -592,7 +608,7 @@ def create_vpc(module, vpc_conn):
...
@@ -592,7 +608,7 @@ def create_vpc(module, vpc_conn):
subnets_in_play
=
len
(
subnets
)
subnets_in_play
=
len
(
subnets
)
returned_subnets
.
sort
(
key
=
lambda
x
:
order
.
get
(
x
[
'cidr'
],
subnets_in_play
))
returned_subnets
.
sort
(
key
=
lambda
x
:
order
.
get
(
x
[
'cidr'
],
subnets_in_play
))
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
):
def
terminate_vpc
(
module
,
vpc_conn
,
vpc_id
=
None
,
cidr
=
None
):
"""
"""
...
@@ -693,6 +709,7 @@ def main():
...
@@ -693,6 +709,7 @@ def main():
else
:
else
:
module
.
fail_json
(
msg
=
"region must be specified"
)
module
.
fail_json
(
msg
=
"region must be specified"
)
igw_dict
=
{}
if
module
.
params
.
get
(
'state'
)
==
'absent'
:
if
module
.
params
.
get
(
'state'
)
==
'absent'
:
vpc_id
=
module
.
params
.
get
(
'vpc_id'
)
vpc_id
=
module
.
params
.
get
(
'vpc_id'
)
cidr
=
module
.
params
.
get
(
'cidr_block'
)
cidr
=
module
.
params
.
get
(
'cidr_block'
)
...
@@ -700,9 +717,9 @@ def main():
...
@@ -700,9 +717,9 @@ def main():
subnets_changed
=
None
subnets_changed
=
None
elif
module
.
params
.
get
(
'state'
)
==
'present'
:
elif
module
.
params
.
get
(
'state'
)
==
'present'
:
# Changed is always set to true when provisioning a new VPC
# 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
# import module snippets
from
ansible.module_utils.basic
import
*
from
ansible.module_utils.basic
import
*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment