mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-28 13:21:25 -07:00
conditional: fix direct boolean "shortcut" (#47941)
* conditional: fix direct boolean "shortcut" * Add unit tests
This commit is contained in:
parent
3a4ee965f5
commit
421d67f1ee
2 changed files with 19 additions and 4 deletions
|
@ -92,10 +92,6 @@ class Conditional:
|
|||
ds = getattr(self, '_ds')
|
||||
|
||||
try:
|
||||
# this allows for direct boolean assignments to conditionals "when: False"
|
||||
if isinstance(self.when, bool):
|
||||
return self.when
|
||||
|
||||
for conditional in self.when:
|
||||
if not self._check_conditional(conditional, templar, all_vars):
|
||||
return False
|
||||
|
@ -117,6 +113,10 @@ class Conditional:
|
|||
if conditional is None or conditional == '':
|
||||
return True
|
||||
|
||||
# this allows for direct boolean assignments to conditionals "when: False"
|
||||
if isinstance(conditional, bool):
|
||||
return conditional
|
||||
|
||||
if templar.is_template(conditional):
|
||||
display.warning('when statements should not include jinja2 '
|
||||
'templating delimiters such as {{ }} or {%% %%}. '
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue