include_vars - fix including new hash variables when hash_behaviour is set to merge (#84303)

pull/84316/head
Sloane Hertel 2 weeks ago committed by GitHub
parent e14f9fe725
commit 3e82ed307b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,2 @@
bugfixes:
- include_vars - fix including previously undefined hash variables with hash_behaviour merge (https://github.com/ansible/ansible/issues/84295).

@ -142,9 +142,8 @@ class ActionModule(ActionBase):
result['message'] = err_msg
elif self.hash_behaviour is not None and self.hash_behaviour != C.DEFAULT_HASH_BEHAVIOUR:
merge_hashes = self.hash_behaviour == 'merge'
for key, value in results.items():
old_value = task_vars.get(key, None)
results[key] = combine_vars(old_value, value, merge=merge_hashes)
existing_variables = {k: v for k, v in task_vars.items() if k in results}
results = combine_vars(existing_variables, results, merge=merge_hashes)
result['ansible_included_var_files'] = self.included_files
result['ansible_facts'] = results

@ -3,3 +3,5 @@ config:
key1: 1
key2: { b: 22 }
key3: 3
previously_undefined:
key1: { a: 1 }

Loading…
Cancel
Save