Skip to content

Commit

Permalink
Set hosts fact gathering flag based on fact cache entries
Browse files Browse the repository at this point in the history
  • Loading branch information
jimi-c committed Sep 3, 2015
1 parent 7ece767 commit 4ac2baf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lib/ansible/executor/play_iterator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand All @@ -121,6 +121,10 @@ def __init__(self, inventory, play, play_context, all_vars):
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:
Expand Down
8 changes: 7 additions & 1 deletion lib/ansible/executor/task_queue_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,13 @@ def run(self, play):
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)
Expand Down

0 comments on commit 4ac2baf

Please sign in to comment.