Move HostVars instantiation to VariableManager

Change:
- TQM was only using this for its side effect. Let VariableManager do
  the work instead.

Test Plan:
- CI

Signed-off-by: Rick Elrod <rick@elrod.me>
pull/71512/head
Rick Elrod 4 years ago
parent d083307e36
commit ebb96623a1

@ -0,0 +1,3 @@
minor_changes:
- hostvars - ``HostVars`` is now instantiated in ``VariableManager`` instead of in ``TaskQueueManager``
- hostvars - removed unused ``HostVars#set_variable_manager``

@ -38,7 +38,6 @@ from ansible.playbook.task import Task
from ansible.plugins.loader import callback_loader, strategy_loader, module_loader
from ansible.plugins.callback import CallbackBase
from ansible.template import Templar
from ansible.vars.hostvars import HostVars
from ansible.vars.reserved import warn_if_reserved
from ansible.utils.display import Display
from ansible.utils.lock import lock_decorator
@ -237,12 +236,6 @@ class TaskQueueManager:
new_play.post_validate(templar)
new_play.handlers = new_play.compile_roles_handlers() + new_play.handlers
self.hostvars = HostVars(
inventory=self._inventory,
variable_manager=self._variable_manager,
loader=self._loader,
)
play_context = PlayContext(new_play, self.passwords, self._connection_lockfile.fileno())
if (self._stdout_callback and
hasattr(self._stdout_callback, 'set_play_context')):

@ -50,13 +50,8 @@ class HostVars(Mapping):
def __init__(self, inventory, variable_manager, loader):
self._inventory = inventory
self._loader = loader
self._variable_manager = variable_manager
variable_manager._hostvars = self
def set_variable_manager(self, variable_manager):
self._variable_manager = variable_manager
variable_manager._hostvars = self
self._loader = loader
def set_inventory(self, inventory):
self._inventory = inventory

@ -46,6 +46,7 @@ from ansible.utils.listify import listify_lookup_plugin_terms
from ansible.utils.vars import combine_vars, load_extra_vars, load_options_vars
from ansible.utils.unsafe_proxy import wrap_var
from ansible.vars.clean import namespace_facts, clean_facts
from ansible.vars.hostvars import HostVars
from ansible.vars.plugins import get_vars_from_inventory_sources, get_vars_from_path
display = Display()
@ -85,8 +86,11 @@ class VariableManager:
self._group_vars_files = defaultdict(dict)
self._inventory = inventory
self._loader = loader
self._hostvars = None
self._omit_token = '__omit_place_holder__%s' % sha1(os.urandom(64)).hexdigest()
self._hostvars = HostVars(
inventory=self._inventory,
variable_manager=self,
loader=self._loader)
self._options_vars = load_options_vars(version_info)

Loading…
Cancel
Save