diff options
author | James Cammarata <jimi@sngx.net> | 2015-09-03 14:10:39 -0400 |
---|---|---|
committer | James Cammarata <jimi@sngx.net> | 2015-09-03 14:11:19 -0400 |
commit | 4ac2bafc4baa59d06c937eb8cb9ade0c6ae45a92 (patch) | |
tree | d0199dc049ddc73a30afd84ddfd608b87c97ce3c | |
parent | 7ece76776791ba4bccf2d346738dd1bf2f735bb1 (diff) | |
download | ansible-4ac2bafc4baa59d06c937eb8cb9ade0c6ae45a92.tar.gz |
Set hosts fact gathering flag based on fact cache entries
Fixes #12213
-rw-r--r-- | lib/ansible/executor/play_iterator.py | 6 | ||||
-rw-r--r-- | lib/ansible/executor/task_queue_manager.py | 8 |
2 files changed, 12 insertions, 2 deletions
diff --git a/lib/ansible/executor/play_iterator.py b/lib/ansible/executor/play_iterator.py index 675d0640d5..cebfd96701 100644 --- a/lib/ansible/executor/play_iterator.py +++ b/lib/ansible/executor/play_iterator.py @@ -109,7 +109,7 @@ class PlayIterator: FAILED_RESCUE = 4 FAILED_ALWAYS = 8 - def __init__(self, inventory, play, play_context, all_vars): + def __init__(self, inventory, play, play_context, variable_manager, all_vars): self._play = play self._blocks = [] @@ -121,6 +121,10 @@ class PlayIterator: self._host_states = {} for host in inventory.get_hosts(self._play.hosts): self._host_states[host.name] = HostState(blocks=self._blocks) + # if the host's name is in the variable manager's fact cache, then set + # its _gathered_facts flag to true for smart gathering tests later + if host.name in variable_manager._fact_cache: + host._gathered_facts = True # if we're looking to start at a specific task, iterate through # the tasks for this host until we find the specified task if play_context.start_at_task is not None: diff --git a/lib/ansible/executor/task_queue_manager.py b/lib/ansible/executor/task_queue_manager.py index 0a1e25ea49..491f916d97 100644 --- a/lib/ansible/executor/task_queue_manager.py +++ b/lib/ansible/executor/task_queue_manager.py @@ -197,7 +197,13 @@ class TaskQueueManager: raise AnsibleError("Invalid play strategy specified: %s" % new_play.strategy, obj=play._ds) # build the iterator - iterator = PlayIterator(inventory=self._inventory, play=new_play, play_context=play_context, all_vars=all_vars) + iterator = PlayIterator( + inventory=self._inventory, + play=new_play, + play_context=play_context, + variable_manager=self._variable_manager, + all_vars=all_vars, + ) # and run the play using the strategy return strategy.run(iterator, play_context) |