Signed-off-by: Yadnesh Kulkarni <ykulkarn@redhat.com>
This commit is contained in:
parent
18e5628b19
commit
3add96909d
4 changed files with 21 additions and 1 deletions
2
changelogs/fragments/72545_fix_facts_value_empty_key.yml
Normal file
2
changelogs/fragments/72545_fix_facts_value_empty_key.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
bugfixes:
|
||||
- Fix parsing of values when using empty string as a key (https://github.com/ansible/ansible/issues/57132)
|
|
@ -797,7 +797,7 @@ class Templar:
|
|||
set to True, the given data will be wrapped as a jinja2 variable ('{{foo}}')
|
||||
before being sent through the template engine.
|
||||
'''
|
||||
static_vars = [''] if static_vars is None else static_vars
|
||||
static_vars = [] if static_vars is None else static_vars
|
||||
|
||||
# Don't template unsafe variables, just return them.
|
||||
if hasattr(variable, '__UNSAFE__'):
|
||||
|
|
|
@ -28,3 +28,6 @@ ansible-playbook -i inventory --flush-cache "$@" set_fact_no_cache.yml
|
|||
# Test boolean conversions in set_fact
|
||||
ANSIBLE_JINJA2_NATIVE=0 ansible-playbook -v set_fact_bool_conv.yml
|
||||
ANSIBLE_JINJA2_NATIVE=1 ansible-playbook -v set_fact_bool_conv_jinja2_native.yml
|
||||
|
||||
# Test parsing of values when using an empty string as a key
|
||||
ansible-playbook -i inventory set_fact_empty_str_key.yml
|
||||
|
|
15
test/integration/targets/set_fact/set_fact_empty_str_key.yml
Normal file
15
test/integration/targets/set_fact/set_fact_empty_str_key.yml
Normal file
|
@ -0,0 +1,15 @@
|
|||
- name: Test set_fact for empty string as a key
|
||||
hosts: testhost
|
||||
gather_facts: no
|
||||
vars:
|
||||
value: 1
|
||||
tasks:
|
||||
- name: Define fact with key as an empty string
|
||||
set_fact:
|
||||
foo:
|
||||
"": "bar{{ value }}"
|
||||
|
||||
- name: Verify the parsed value of the key
|
||||
assert:
|
||||
that:
|
||||
- foo == {"":"bar1"}
|
Loading…
Reference in a new issue