mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Make gathering=explicit work again
There was a confusion between the valid values for defaults.gathering (explicit/implicit/smart) and a play's gather_facts setting (boolean), which resulted in gathering=explicit being ignored.
This commit is contained in:
parent
d70c88bf8c
commit
28e2eae902
2 changed files with 14 additions and 2 deletions
|
@ -19,6 +19,8 @@
|
|||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
from ansible import constants as C
|
||||
|
||||
from ansible.errors import *
|
||||
from ansible.playbook.block import Block
|
||||
from ansible.playbook.task import Task
|
||||
|
@ -130,7 +132,17 @@ class PlayIterator:
|
|||
elif s.run_state == self.ITERATING_SETUP:
|
||||
s.run_state = self.ITERATING_TASKS
|
||||
s.pending_setup = True
|
||||
if self._play.gather_facts == 'smart' and not host._gathered_facts or boolean(self._play.gather_facts):
|
||||
|
||||
# Gather facts if the default is 'smart' and we have not yet
|
||||
# done it for this host; or if 'explicit' and the play sets
|
||||
# gather_facts to True; or if 'implicit' and the play does
|
||||
# NOT explicitly set gather_facts to False.
|
||||
|
||||
gathering = C.DEFAULT_GATHERING
|
||||
if ((gathering == 'smart' and not host._gathered_facts) or
|
||||
(gathering == 'explicit' and boolean(self._play.gather_facts)) or
|
||||
(gathering == 'implicit' and
|
||||
(self._play.gather_facts is None or boolean(self._play.gather_facts)))):
|
||||
if not peek:
|
||||
# mark the host as having gathered facts
|
||||
host.set_gathered_facts(True)
|
||||
|
|
|
@ -58,7 +58,7 @@ class Play(Base, Taggable, Become):
|
|||
_accelerate_port = FieldAttribute(isa='int', default=5099) # should be alias of port
|
||||
|
||||
# Connection
|
||||
_gather_facts = FieldAttribute(isa='string', default='smart')
|
||||
_gather_facts = FieldAttribute(isa='bool', default=None)
|
||||
_hosts = FieldAttribute(isa='list', default=[], required=True, listof=string_types)
|
||||
_name = FieldAttribute(isa='string', default='')
|
||||
|
||||
|
|
Loading…
Reference in a new issue