@@ -246,6 +246,40 @@ Valid options are:
246
246
This optional warning and failure behavior is experimental and subject to change in future versions.
247
247
248
248
249
+ Loops no longer leak omit placeholders
250
+ --------------------------------------
251
+
252
+ Omit placeholders no longer leak between loop item templating and task templating.
253
+
254
+ Previously, ``omit `` placeholders could remain embedded in loop items after templating and be used as an ``omit `` for task templating.
255
+ Now, values resolving to ``omit `` are dropped immediately when loop items are templated.
256
+
257
+ To turn missing values into an ``omit `` for task templating, use ``| default(omit) ``.
258
+ This solution is backward compatible with previous versions of ``ansible-core ``.
259
+
260
+ Example - missing default(omit)
261
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
262
+
263
+ The following task tries to pass ``omit `` from a loop to the task, but the value is undefined since it was omitted:
264
+
265
+ .. code-block :: yaml+jinja
266
+
267
+ - debug:
268
+ msg: "{{ item.msg }}" # 'msg' is undefined
269
+ loop:
270
+ - msg: "{{ omit }}" # 'msg' will be omitted from the loop item
271
+
272
+
273
+ This updated task uses ``default(omit) `` on the missing value to ensure it is omitted for the task:
274
+
275
+ .. code-block :: yaml+jinja
276
+
277
+ - debug:
278
+ msg: "{{ item.msg | default(omit) }}" # 'msg' is undefined, use 'default(omit)' to turn it into an omit
279
+ loop:
280
+ - msg: "{{ omit }}" # passed through in earlier versions, this value is now omitted from the loop item
281
+
282
+
249
283
Privilege escalation timeouts
250
284
-----------------------------
251
285
@@ -560,6 +594,62 @@ templates.
560
594
This section and the associated public API are currently incomplete.
561
595
562
596
597
+ Raising exceptions
598
+ ------------------
599
+
600
+ When raising exceptions in an exception handler, be sure to use ``raise ... from `` as appropriate.
601
+ This supersedes the use of the ``AnsibleError `` arg ``orig_exc `` to represent the cause.
602
+ Specifying ``orig_exc `` as the cause is still permitted for backward compatibility.
603
+
604
+ Failure to use ``raise ... from `` when ``orig_exc `` is set will result in a warning.
605
+ Additionally, if the two cause exceptions do not match, a warning will be issued.
606
+
607
+
608
+ Overly-broad exception handling in Jinja plugins
609
+ ------------------------------------------------
610
+
611
+ Jinja plugins with overly broad exception handling, such as ``except Exception ``,
612
+ may behave incorrectly when accessing the contents of variables which are containers (``dict ``, ``list ``).
613
+ This can occur when a templated value from a variable is undefined,
614
+ is an undecryptable vaulted value, or another value which triggers lazily reported fault conditions.
615
+
616
+ Jinja plugins should catch more specific exception types where possible,
617
+ and do so around the smallest reasonable portion of code.
618
+ Be especially careful to avoid broad exception handling around code which accesses the contents of container variables.
619
+
620
+
621
+ Ansible custom data types
622
+ -------------------------
623
+
624
+ Many variable objects in ``ansible-core `` are represented by custom types.
625
+ In previous versions these could be seen as types such as:
626
+
627
+ * ``AnsibleUnicode `` (a subclass of ``str ``)
628
+ * ``AnsibleSequence `` (a subclass of ``list ``)
629
+ * ``AnsibleMapping `` (a subclass of ``dict ``)
630
+
631
+ These types, and more, now have new subclasses derived from their native Python types.
632
+ In most cases these types behave indistinguishably from the types they extend, and existing code should function normally.
633
+ However, some Python libraries do not handle builtin object subclasses properly.
634
+ Custom plugins that interact with such libraries may require changes to convert and pass the native types.
635
+
636
+ .. warning ::
637
+ This section and the associated public API are currently incomplete.
638
+
639
+
640
+ AnsibleVaultEncryptedUnicode replaced by EncryptedString
641
+ --------------------------------------------------------
642
+
643
+ The ``AnsibleVaultEncryptedUnicode `` type has been replaced by ``EncryptedString ``.
644
+
645
+ Plugins which create ``AnsibleVaultEncryptedUnicode `` will now receive ``EncryptedString `` instances instead.
646
+ This feature ensures backward compatibility with previous versions of ``ansible-core ``.
647
+
648
+ Plugins which perform ``isinstance `` checks, looking for ``AnsibleVaultEncryptedUnicode ``, will no longer encounter these types.
649
+ Values formerly represented by that type will now appear as a tagged ``str `` instead.
650
+ Special handling in plugins is no longer required to access the contents of these values.
651
+
652
+
563
653
Command Line
564
654
============
565
655
@@ -601,6 +691,9 @@ No notable changes
601
691
Plugins
602
692
=======
603
693
694
+ Noteworthy plugin changes
695
+ -------------------------
696
+
604
697
* The ``ssh `` connection plugin now supports using ``SSH_ASKPASS `` to supply passwords
605
698
for authentication as an alternative to the ``sshpass `` program. The default is to use
606
699
``SSH_ASKPASS `` instead of ``sshpass ``. This is controlled by the ``password_mechanism ``
@@ -626,6 +719,20 @@ Plugins
626
719
627
720
ansible_ssh_password_mechanism : sshpass
628
721
722
+ * Coercing unrecognized input values in the ``bool `` filter is deprecated.
723
+ The ``bool `` filter now returns only ``True `` or ``False ``, depending on the input:
724
+
725
+ * ``True `` - Returned for ``True ``, ``1 `` and case-insensitive matches on the strings: "yes", "on", "true", "1"
726
+ * ``False `` - Returned for ``False ``, ``0 `` and case-insensitive matches on the strings: "no", "off", "false", "0"
727
+
728
+ Any other input will result in a deprecation warning. This warning will become an error in ``ansible-core `` 2.23.
729
+
730
+ When a deprecation warning is issued, the return value is ``False `` unless the input equals ``1 ``,
731
+ which can occur when the input is the ``float `` value of ``1.0 ``.
732
+
733
+ This filter now returns ``False `` instead of ``None `` when the input is ``None ``.
734
+ The aforementioned deprecation warning is also issued in this case.
735
+
629
736
630
737
Porting custom scripts
631
738
======================
0 commit comments