mirror of https://github.com/ansible/ansible.git
improve conditional warnings (#57190)
* Fix order for warning on templated conditionals Fix bare variable warnings when the variable is a boolean * changelog * Add tests for cases that should and should not give warnings If the behavior may change when the default behavior for CONDITIONAL_BARE_VARS becomes False there should be a warning. Boolean type conditionals will not change in behavior so don't warn. * oops, forgot to add files * typopull/57305/head
parent
fecffea370
commit
21cd24a0dd
@ -0,0 +1,3 @@
|
|||||||
|
bugfixes:
|
||||||
|
- Only warn for bare variables if they are not type boolean (https://github.com/ansible/ansible/issues/53428)
|
||||||
|
- Fix regression warning on jinja2 delimiters in when statements (https://github.com/ansible/ansible/issues/56830)
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
- hosts: testhost
|
||||||
|
gather_facts: false
|
||||||
|
vars:
|
||||||
|
boolean_var: false
|
||||||
|
nested:
|
||||||
|
bool_var: false
|
||||||
|
tasks:
|
||||||
|
- name: Run tasks with previous warnings requesting the bool filter on type boolean vars
|
||||||
|
block:
|
||||||
|
- debug:
|
||||||
|
when: boolean_var
|
||||||
|
- debug:
|
||||||
|
when: nested.bool_var
|
||||||
|
- debug:
|
||||||
|
when: double_interpolated
|
||||||
|
vars:
|
||||||
|
double_interpolated: "{{ other }}"
|
||||||
|
other: false
|
||||||
@ -0,0 +1,14 @@
|
|||||||
|
- hosts: testhost
|
||||||
|
gather_facts: false
|
||||||
|
vars:
|
||||||
|
str_boolean_var: 'false'
|
||||||
|
tasks:
|
||||||
|
- name: Run tasks with warnings for conditionals that will change in behavior depending on CONDITIONAL_BARE_VARS
|
||||||
|
block:
|
||||||
|
- debug:
|
||||||
|
when: str_boolean_var
|
||||||
|
- debug:
|
||||||
|
when: double_interpolated
|
||||||
|
vars:
|
||||||
|
double_interpolated: other
|
||||||
|
other: false
|
||||||
Loading…
Reference in New Issue