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:
parent
d8bf4206e4
commit
3740d7b028
4 changed files with 9 additions and 2 deletions
3
changelogs/fragments/73926-is-template-play-hosts.yml
Normal file
3
changelogs/fragments/73926-is-template-play-hosts.yml
Normal 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)
|
|
@ -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:
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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'
|
||||
|
|
Loading…
Reference in a new issue