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
f12695f2
Commit
f12695f2
authored
10 years ago
by
James Cammarata
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add run_once/BYPASS_HOST_LOOP feature in v2
parent
4af2d0a9
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
0 deletions
+24
-0
v2/ansible/executor/task_executor.py
+1
-0
v2/ansible/plugins/__init__.py
+3
-0
v2/ansible/plugins/strategies/linear.py
+14
-0
v2/samples/test_run_once.yml
+6
-0
No files found.
v2/ansible/executor/task_executor.py
View file @
f12695f2
...
...
@@ -359,6 +359,7 @@ class TaskExecutor:
loader
=
self
.
_loader
,
module_loader
=
self
.
_module_loader
,
)
if
not
handler
:
raise
AnsibleError
(
"the handler '
%
s' was not found"
%
handler_name
)
...
...
This diff is collapsed.
Click to expand it.
v2/ansible/plugins/__init__.py
View file @
f12695f2
...
...
@@ -221,6 +221,9 @@ class PluginLoader:
path
=
self
.
find_plugin
(
name
)
if
path
is
None
:
return
None
elif
kwargs
.
get
(
'class_only'
,
False
):
return
getattr
(
self
.
_module_cache
[
path
],
self
.
class_name
)
if
path
not
in
self
.
_module_cache
:
self
.
_module_cache
[
path
]
=
imp
.
load_source
(
'.'
.
join
([
self
.
package
,
name
]),
path
)
return
getattr
(
self
.
_module_cache
[
path
],
self
.
class_name
)(
*
args
,
**
kwargs
)
...
...
This diff is collapsed.
Click to expand it.
v2/ansible/plugins/strategies/linear.py
View file @
f12695f2
...
...
@@ -22,6 +22,7 @@ __metaclass__ = type
from
ansible.errors
import
AnsibleError
from
ansible.executor.play_iterator
import
PlayIterator
from
ansible.playbook.task
import
Task
from
ansible.plugins
import
action_loader
from
ansible.plugins.strategies
import
StrategyBase
from
ansible.utils.debug
import
debug
...
...
@@ -143,8 +144,17 @@ class StrategyModule(StrategyBase):
if
not
task
:
continue
run_once
=
False
work_to_do
=
True
# test to see if the task across all hosts points to an action plugin which
# sets BYPASS_HOST_LOOP to true, or if it has run_once enabled. If so, we
# will only send this task to the first host in the list.
action
=
action_loader
.
get
(
task
.
action
,
class_only
=
True
)
if
task
.
run_once
or
getattr
(
action
,
'BYPASS_HOST_LOOP'
,
False
):
run_once
=
True
debug
(
"getting variables"
)
task_vars
=
self
.
_variable_manager
.
get_vars
(
loader
=
self
.
_loader
,
play
=
iterator
.
_play
,
host
=
host
,
task
=
task
)
debug
(
"done getting variables"
)
...
...
@@ -183,6 +193,10 @@ class StrategyModule(StrategyBase):
self
.
_process_pending_results
(
iterator
)
# if we're bypassing the host loop, break out now
if
run_once
:
break
debug
(
"done queuing things up, now waiting for results queue to drain"
)
self
.
_wait_on_pending_results
(
iterator
)
...
...
This diff is collapsed.
Click to expand it.
v2/samples/test_run_once.yml
0 → 100644
View file @
f12695f2
-
hosts
:
all
gather_facts
:
no
tasks
:
-
ping
:
run_once
:
yes
-
add_host
:
name=foo
This diff is collapsed.
Click to expand it.
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