Only check if play.hosts is a template when the play hasn't been finalized (#73941)

* Extend finalized logic to strategy
* Add changelog fragment
pull/66269/head
Matt Martz 4 years ago committed by GitHub
parent d8bf4206e4
commit 3740d7b028
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,3 @@
bugfixes:
- Variable Manager - Only check if ``play.hosts`` is a template when the play
hasn't been finalized (https://github.com/ansible/ansible/issues/73926)

@ -180,6 +180,10 @@ class FieldAttributeBase(with_metaclass(BaseMeta, object)):
# and init vars, avoid using defaults in field declaration as it lives across plays # and init vars, avoid using defaults in field declaration as it lives across plays
self.vars = dict() self.vars = dict()
@property
def finalized(self):
return self._finalized
def dump_me(self, depth=0): def dump_me(self, depth=0):
''' this is never called from production code, it is here to be used when debugging as a 'complex print' ''' ''' this is never called from production code, it is here to be used when debugging as a 'complex print' '''
if depth == 0: if depth == 0:

@ -251,7 +251,7 @@ class StrategyBase:
if not refresh and all((self._hosts_cache, self._hosts_cache_all)): if not refresh and all((self._hosts_cache, self._hosts_cache_all)):
return return
if Templar(None).is_template(play.hosts): if not play.finalized and Templar(None).is_template(play.hosts):
_pattern = 'all' _pattern = 'all'
else: else:
_pattern = play.hosts or 'all' _pattern = play.hosts or 'all'

@ -487,7 +487,7 @@ class VariableManager:
variables['groups'] = self._inventory.get_groups_dict() variables['groups'] = self._inventory.get_groups_dict()
if play: if play:
templar = Templar(loader=self._loader) templar = Templar(loader=self._loader)
if templar.is_template(play.hosts): if not play.finalized and templar.is_template(play.hosts):
pattern = 'all' pattern = 'all'
else: else:
pattern = play.hosts or 'all' pattern = play.hosts or 'all'

Loading…
Cancel
Save