mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-25 20:01:25 -07:00
Store hosts for a play as a play attribute
Operate on that play attribute to make things faster for larger inventories. Instead of making a round trip through inventory.list_hosts and working through some lengthy list comprehensions over and over again, calculate the potenital hosts for a play once, then reduce from it the unavailable hosts when necessary. Also moves how the %fail is done. The host count is a play level count of available hosts, which then is compared after each task to the current number of available hosts for the play. This used to get a new count every task which was also time expensive.
This commit is contained in:
parent
94f3b9bfab
commit
e8ad36c8d4
2 changed files with 19 additions and 11 deletions
|
@ -34,7 +34,7 @@ class Play(object):
|
|||
'handlers', 'remote_user', 'remote_port', 'included_roles', 'accelerate',
|
||||
'accelerate_port', 'accelerate_ipv6', 'sudo', 'sudo_user', 'transport', 'playbook',
|
||||
'tags', 'gather_facts', 'serial', '_ds', '_handlers', '_tasks',
|
||||
'basedir', 'any_errors_fatal', 'roles', 'max_fail_pct'
|
||||
'basedir', 'any_errors_fatal', 'roles', 'max_fail_pct', '_play_hosts'
|
||||
]
|
||||
|
||||
# to catch typos and so forth -- these are userland names
|
||||
|
@ -134,6 +134,8 @@ class Play(object):
|
|||
if self.sudo_user != 'root':
|
||||
self.sudo = True
|
||||
|
||||
# place holder for the discovered hosts to be used in this play
|
||||
self._play_hosts = None
|
||||
|
||||
# *************************************************
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue