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

* Extend finalized logic to strategy
* Add changelog fragment
This commit is contained in:
Matt Martz 2021-04-19 12:03:40 -05:00 committed by GitHub
parent d8bf4206e4
commit 3740d7b028
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 2 deletions

View file

@ -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)

View file

@ -180,6 +180,10 @@ class FieldAttributeBase(with_metaclass(BaseMeta, object)):
# and init vars, avoid using defaults in field declaration as it lives across plays
self.vars = dict()
@property
def finalized(self):
return self._finalized
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' '''
if depth == 0:

View file

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

View file

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