mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-25 14:20:22 -07:00
Add 'pause' action plugin and support plugins skipping the host loop.
This commit is contained in:
parent
27d3ac9dc6
commit
58a4d2f7b4
3 changed files with 172 additions and 11 deletions
|
@ -563,7 +563,26 @@ class Runner(object):
|
|||
|
||||
hosts = [ (self,x) for x in hosts ]
|
||||
results = None
|
||||
if self.forks > 1:
|
||||
|
||||
# Check if this is an action plugin. Some of them are designed
|
||||
# to be ran once per group of hosts. Example module: pause,
|
||||
# run once per hostgroup, rather than pausing once per each
|
||||
# host.
|
||||
p = self.action_plugins.get(self.module_name, None)
|
||||
if p and getattr(p, 'BYPASS_HOST_LOOP', None):
|
||||
# Expose the current hostgroup to the bypassing plugins
|
||||
self.host_set = hosts
|
||||
# We aren't iterating over all the hosts in this
|
||||
# group. So, just pick the first host in our group to
|
||||
# construct the conn object with.
|
||||
result_data = self._executor(hosts[0][1]).result
|
||||
# Create a ResultData item for each host in this group
|
||||
# using the returned result. If we didn't do this we would
|
||||
# get false reports of dark hosts.
|
||||
results = [ ReturnData(host=h[1], result=result_data, comm_ok=True) \
|
||||
for h in hosts ]
|
||||
del self.host_set
|
||||
elif self.forks > 1:
|
||||
results = self._parallel_exec(hosts)
|
||||
else:
|
||||
results = [ self._executor(h[1]) for h in hosts ]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue