From f8167d7a8ae8f4860dfabd2190e8ff547d9dd271 Mon Sep 17 00:00:00 2001 From: Abhijeet Kasurde Date: Mon, 3 Nov 2025 09:05:40 -0800 Subject: [PATCH] Update porting guide about undefined variable error * With 2.19, undefined variable in var_files raises an error Signed-off-by: Abhijeet Kasurde --- .../porting_guide_core_2.19.rst | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/docs/docsite/rst/porting_guides/porting_guide_core_2.19.rst b/docs/docsite/rst/porting_guides/porting_guide_core_2.19.rst index 9ac350ad39..6550541eaa 100644 --- a/docs/docsite/rst/porting_guides/porting_guide_core_2.19.rst +++ b/docs/docsite/rst/porting_guides/porting_guide_core_2.19.rst @@ -633,6 +633,31 @@ Valid options are: Multiple options can be combined by separating them with commas. +Displaying error when undefined variables in var_files +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +In previous versions of ``ansible-core``, undefined variables from var_files were silently ignored and did not trigger errors. +This is now changed and an error will be displayed when undefined variables in var_files are encountered. + +.. code-block:: yaml+jinja + + - hosts: all + vars_files: + - "{{ inventory_dir }}/vars_files/foo.yml" + +.. code-block:: ansible-output + + PLAYBOOK: foo.yml ************************************************************************ + 1 plays in foo.yml + [WARNING]: skipping vars_file item due to an undefined variable + Origin: /examples/foo.yml:6:7 + + 4 + 5 vars_files: + 6 - "{{ inventory_dir }}/vars_files/foo.yml" + ^ column 7 + + .. _plugin_api: Plugin API