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
f9d451eb
Commit
f9d451eb
authored
Jan 20, 2015
by
James Cammarata
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding post-validation method to connection info object
parent
364f772c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
1 deletions
+28
-1
v2/ansible/executor/connection_info.py
+14
-0
v2/ansible/executor/task_executor.py
+12
-1
v2/ansible/playbook/task_include.py
+2
-0
No files found.
v2/ansible/executor/connection_info.py
View file @
f9d451eb
...
...
@@ -23,6 +23,7 @@ import pipes
import
random
from
ansible
import
constants
as
C
from
ansible.template
import
Templar
__all__
=
[
'ConnectionInformation'
]
...
...
@@ -182,3 +183,16 @@ class ConnectionInformation:
#return ('/bin/sh -c ' + pipes.quote(sudocmd), prompt, success_key)
return
(
sudocmd
,
prompt
,
success_key
)
def
_get_fields
(
self
):
return
[
i
for
i
in
self
.
__dict__
.
keys
()
if
i
[:
1
]
!=
'_'
]
def
post_validate
(
self
,
variables
,
loader
):
'''
Finalizes templated values which may be set on this objects fields.
'''
templar
=
Templar
(
loader
=
loader
,
variables
=
variables
)
for
field
in
self
.
_get_fields
():
value
=
templar
.
template
(
getattr
(
self
,
field
))
setattr
(
self
,
field
,
value
)
v2/ansible/executor/task_executor.py
View file @
f9d451eb
...
...
@@ -167,15 +167,26 @@ class TaskExecutor:
if
variables
is
None
:
variables
=
self
.
_job_vars
# fields set from the play/task may be based on variables, so we have to
# do the same kind of post validation step on it here before we use it
self
.
_connection_info
.
post_validate
(
variables
=
variables
,
loader
=
self
.
_loader
)
# get the connection and the handler for this execution
self
.
_connection
=
self
.
_get_connection
()
self
.
_handler
=
self
.
_get_action_handler
(
connection
=
self
.
_connection
)
# Evaluate the conditional (if any) for this task, which we do before running
# the final task post-validation. We do this before the post validation due to
# the fact that the conditional may specify that the task be skipped due to a
# variable not being present which would otherwise cause validation to fail
if
not
self
.
_task
.
evaluate_conditional
(
variables
):
debug
(
"when evaulation failed, skipping this task"
)
return
dict
(
changed
=
False
,
skipped
=
True
,
skip_reason
=
'Conditional check failed'
)
# Now we do final validation on the task, which sets all fields to their final values
self
.
_task
.
post_validate
(
variables
)
# Read some values from the task, so that we can modify them if need be
retries
=
self
.
_task
.
retries
if
retries
<=
0
:
retries
=
1
...
...
@@ -192,7 +203,7 @@ class TaskExecutor:
result
=
None
for
attempt
in
range
(
retries
):
if
attempt
>
0
:
# FIXME: this should use the callback mechanism
# FIXME: this should use the callback
/message passing
mechanism
print
(
"FAILED - RETRYING:
%
s (
%
d retries left)"
%
(
self
.
_task
,
retries
-
attempt
))
result
[
'attempts'
]
=
attempt
+
1
...
...
v2/ansible/playbook/task_include.py
View file @
f9d451eb
...
...
@@ -175,6 +175,8 @@ class TaskInclude(Base, Conditional, Taggable):
all_vars
=
dict
()
if
self
.
_task_include
:
all_vars
.
update
(
self
.
_task_include
.
get_vars
())
if
self
.
_block
:
all_vars
.
update
(
self
.
_block
.
get_vars
())
all_vars
.
update
(
self
.
vars
)
return
all_vars
...
...
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