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
fd67a207
Commit
fd67a207
authored
Jan 07, 2015
by
James Cammarata
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed "until" loop support, and cleaned up the async_wrapper/polling a bit
parent
065733ad
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
16 deletions
+24
-16
v2/ansible/executor/task_executor.py
+23
-15
v2/ansible/playbook/task.py
+1
-1
No files found.
v2/ansible/executor/task_executor.py
View file @
fd67a207
...
...
@@ -137,7 +137,7 @@ class TaskExecutor:
delay
=
self
.
_task
.
delay
if
delay
<
0
:
delay
=
0
delay
=
1
debug
(
"starting attempt loop"
)
result
=
None
...
...
@@ -151,14 +151,29 @@ class TaskExecutor:
result
=
self
.
_handler
.
run
(
task_vars
=
self
.
_job_vars
)
debug
(
"handler run complete"
)
if
self
.
_task
.
async
>
0
and
self
.
_task
.
poll
>
0
:
result
=
self
.
_poll_async_result
(
result
=
result
)
if
self
.
_task
.
async
>
0
:
# the async_wrapper module returns dumped JSON via its stdout
# response, so we parse it here and replace the result
try
:
result
=
json
.
loads
(
result
.
get
(
'stdout'
))
except
ValueError
,
e
:
return
dict
(
failed
=
True
,
msg
=
"The async task did not return valid JSON:
%
s"
%
str
(
e
))
if
self
.
_task
.
poll
>
0
:
result
=
self
.
_poll_async_result
(
result
=
result
)
if
self
.
_task
.
until
:
# TODO: implement until logic (pseudo logic follows...)
# if VariableManager.check_conditional(cond, extra_vars=(dict(result=result))):
# break
pass
# make a copy of the job vars here, in case we need to update them
vars_copy
=
self
.
_job_vars
.
copy
()
# now update them with the registered value, if it is set
if
self
.
_task
.
register
:
vars_copy
[
self
.
_task
.
register
]
=
result
# now create a pseudo task, and assign the value of the until parameter
# to the when param, so we can use evaluate_conditional()
pseudo_task
=
Task
()
pseudo_task
.
when
=
self
.
_task
.
until
if
pseudo_task
.
evaluate_conditional
(
vars_copy
):
break
elif
'failed'
not
in
result
and
result
.
get
(
'rc'
,
0
)
==
0
:
# if the result is not failed, stop trying
break
...
...
@@ -174,14 +189,7 @@ class TaskExecutor:
Polls for the specified JID to be complete
'''
# the async_wrapper module returns dumped JSON via its stdout
# response, so we parse it here
try
:
async_data
=
json
.
loads
(
result
.
get
(
'stdout'
))
except
ValueError
,
e
:
return
dict
(
failed
=
True
,
msg
=
"The async task did not return valid JSON:
%
s"
%
str
(
e
))
async_jid
=
async_data
.
get
(
'ansible_job_id'
)
async_jid
=
result
.
get
(
'ansible_job_id'
)
if
async_jid
is
None
:
return
dict
(
failed
=
True
,
msg
=
"No job id was returned by the async task"
)
...
...
v2/ansible/playbook/task.py
View file @
fd67a207
...
...
@@ -61,7 +61,7 @@ class Task(Base, Conditional, Taggable):
_async
=
FieldAttribute
(
isa
=
'int'
,
default
=
0
)
_changed_when
=
FieldAttribute
(
isa
=
'string'
)
_connection
=
FieldAttribute
(
isa
=
'string'
)
_delay
=
FieldAttribute
(
isa
=
'int'
,
default
=
0
)
_delay
=
FieldAttribute
(
isa
=
'int'
,
default
=
5
)
_delegate_to
=
FieldAttribute
(
isa
=
'string'
)
_environment
=
FieldAttribute
(
isa
=
'dict'
)
_failed_when
=
FieldAttribute
(
isa
=
'string'
)
...
...
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