Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
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
OpenEdx
ansible
Commits
ba4838cd
Commit
ba4838cd
authored
Apr 01, 2014
by
James Cammarata
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding wait/wait_timeout parameters to the ec2_key module
Fixes #6455
parent
e2d86e4f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
0 deletions
+40
-0
library/cloud/ec2_key
+40
-0
No files found.
library/cloud/ec2_key
View file @
ba4838cd
...
...
@@ -70,6 +70,20 @@ options:
default: null
aliases: []
version_added: "1.6"
wait:
description:
- Wait for the specified action to complete before returning.
required: false
default: false
aliases: []
version_added: "1.6"
wait_timeout:
description:
- How long before wait gives up, in seconds
required: false
default: 300
aliases: []
version_added: "1.6"
requirements: [ "boto" ]
author: Vincent Viallet
...
...
@@ -124,6 +138,8 @@ def main():
name
=
dict
(
required
=
True
),
key_material
=
dict
(
required
=
False
),
state
=
dict
(
default
=
'present'
,
choices
=
[
'present'
,
'absent'
]),
wait
=
dict
(
type
=
'bool'
,
default
=
False
),
wait_timeout
=
dict
(
default
=
300
),
)
)
module
=
AnsibleModule
(
...
...
@@ -134,6 +150,8 @@ def main():
name
=
module
.
params
[
'name'
]
state
=
module
.
params
.
get
(
'state'
)
key_material
=
module
.
params
.
get
(
'key_material'
)
wait
=
module
.
params
.
get
(
'wait'
)
wait_timeout
=
int
(
module
.
params
.
get
(
'wait_timeout'
))
changed
=
False
...
...
@@ -148,6 +166,16 @@ def main():
'''found a match, delete it'''
try
:
key
.
delete
()
if
wait
:
start
=
time
.
time
()
action_complete
=
False
while
(
time
.
time
()
-
start
)
<
wait_timeout
:
if
not
ec2
.
get_key_pair
(
name
):
action_complete
=
True
break
time
.
sleep
(
1
)
if
not
action_complete
:
module
.
fail_json
(
msg
=
"timed out while waiting for the key to be removed"
)
except
Exception
,
e
:
module
.
fail_json
(
msg
=
"Unable to delete key pair '
%
s' -
%
s"
%
(
key
,
e
))
else
:
...
...
@@ -178,6 +206,18 @@ def main():
retrieve the private key
'''
key
=
ec2
.
create_key_pair
(
name
)
if
wait
:
start
=
time
.
time
()
action_complete
=
False
while
(
time
.
time
()
-
start
)
<
wait_timeout
:
if
ec2
.
get_key_pair
(
name
):
action_complete
=
True
break
time
.
sleep
(
1
)
if
not
action_complete
:
module
.
fail_json
(
msg
=
"timed out while waiting for the key to be created"
)
changed
=
True
if
key
:
...
...
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