summaryrefslogtreecommitdiff
path: root/changelogs
diff options
context:
space:
mode:
authorDaniel Goldman <merkavabuilder@gmail.com>2021-09-20 18:37:36 -0400
committerGitHub <noreply@github.com>2021-09-20 15:37:36 -0700
commit989eeb243fcf9236bd54d4df60c01f6db4e642a7 (patch)
tree209433f599333201838540e0ae29f24c73dbc204 /changelogs
parent47b644570f77e59871de25b4f101ec7f33fa326c (diff)
downloadansible-989eeb243fcf9236bd54d4df60c01f6db4e642a7.tar.gz
Add an `undef` global Jinja function (#75435)
* add tests for fail filter also tests that fail does not block inspectability * add fail filter fallback message is a bit clunky, since you can't invoke a filter without specifying an input. That is, "{{ fail }}" doesn't work, so you have to do "{{ None | fail }}" * document 'fail' filter * add changelog fragment * fail filter uses default message on Undefined or emptystring makes it slightly easier to use the default message: ```diff - "{{ None | fail }}" + "{{ '' | fail }}" ``` and the user sees a slightly more relevant message if the message itself is undefined: ```diff - The error was: {{ failmsg | fail }}: 'failmsg' is undefined + The error was: {{ failmsg | fail }}: Mandatory variable has not been overridden ``` * rebuild as the builtin `Undefined` * harmonise `hint` parameter for make_undefined with jinja * use code block for documentation item [ref](https://github.com/ansible/ansible/pull/75435#discussion_r707661035) * rename to `undef` to expose less Python into the Jinja [ref](https://github.com/ansible/ansible/pull/75435#pullrequestreview-757799031) * explicitly instantiate undefined value now that it's possible see I knew we would break something with reflection * preserve test coverage of undefined variable Co-authored-by: Matt Davis <nitzmahone@users.noreply.github.com>
Diffstat (limited to 'changelogs')
-rw-r--r--changelogs/fragments/75435-creating-Undefined.yml2
1 files changed, 2 insertions, 0 deletions
diff --git a/changelogs/fragments/75435-creating-Undefined.yml b/changelogs/fragments/75435-creating-Undefined.yml
new file mode 100644
index 0000000000..3e2f8bc578
--- /dev/null
+++ b/changelogs/fragments/75435-creating-Undefined.yml
@@ -0,0 +1,2 @@
+minor_changes:
+ - adds the ``undef`` keyword to the templating environment. This allows for directly creating Undefined values in templates. It is most useful for providing a hint for variables which must be overridden.