Skip to content

Commit 901cf8a

Browse files
mariolenzpatchback[bot]
authored andcommitted
Update Ansible 12 porting guide for 12.0.0a2 release (#2562)
* Update Ansible 12 porting guide for 12.0.0a2 release * Update porting guide. --------- Co-authored-by: Felix Fontein <[email protected]> (cherry picked from commit 9424c8c)
1 parent 1441580 commit 901cf8a

File tree

1 file changed

+152
-0
lines changed

1 file changed

+152
-0
lines changed

docs/docsite/rst/porting_guides/porting_guide_12.rst

+152
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,40 @@ Valid options are:
242242
This optional warning and failure behavior is experimental and subject to change in future versions.
243243

244244

245+
Loops no longer leak omit placeholders
246+
--------------------------------------
247+
248+
Omit placeholders no longer leak between loop item templating and task templating.
249+
250+
Previously, ``omit`` placeholders could remain embedded in loop items after templating and be used as an ``omit`` for task templating.
251+
Now, values resolving to ``omit`` are dropped immediately when loop items are templated.
252+
253+
To turn missing values into an ``omit`` for task templating, use ``| default(omit)``.
254+
This solution is backward compatible with previous versions of ``ansible-core``.
255+
256+
Example - missing default(omit)
257+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
258+
259+
The following task tries to pass ``omit`` from a loop to the task, but the value is undefined since it was omitted:
260+
261+
.. code-block:: yaml+jinja
262+
263+
- debug:
264+
msg: "{{ item.msg }}" # 'msg' is undefined
265+
loop:
266+
- msg: "{{ omit }}" # 'msg' will be omitted from the loop item
267+
268+
269+
This updated task uses ``default(omit)`` on the missing value to ensure it is omitted for the task:
270+
271+
.. code-block:: yaml+jinja
272+
273+
- debug:
274+
msg: "{{ item.msg | default(omit) }}" # 'msg' is undefined, use 'default(omit)' to turn it into an omit
275+
loop:
276+
- msg: "{{ omit }}" # passed through in earlier versions, this value is now omitted from the loop item
277+
278+
245279
Privilege escalation timeouts
246280
-----------------------------
247281

@@ -556,6 +590,62 @@ templates.
556590
This section and the associated public API are currently incomplete.
557591

558592

593+
Raising exceptions
594+
------------------
595+
596+
When raising exceptions in an exception handler, be sure to use ``raise ... from`` as appropriate.
597+
This supersedes the use of the ``AnsibleError`` arg ``orig_exc`` to represent the cause.
598+
Specifying ``orig_exc`` as the cause is still permitted for backward compatibility.
599+
600+
Failure to use ``raise ... from`` when ``orig_exc`` is set will result in a warning.
601+
Additionally, if the two cause exceptions do not match, a warning will be issued.
602+
603+
604+
Overly-broad exception handling in Jinja plugins
605+
------------------------------------------------
606+
607+
Jinja plugins with overly broad exception handling, such as ``except Exception``,
608+
may behave incorrectly when accessing the contents of variables which are containers (``dict``, ``list``).
609+
This can occur when a templated value from a variable is undefined,
610+
is an undecryptable vaulted value, or another value which triggers lazily reported fault conditions.
611+
612+
Jinja plugins should catch more specific exception types where possible,
613+
and do so around the smallest reasonable portion of code.
614+
Be especially careful to avoid broad exception handling around code which accesses the contents of container variables.
615+
616+
617+
Ansible custom data types
618+
-------------------------
619+
620+
Many variable objects in ``ansible-core`` are represented by custom types.
621+
In previous versions these could be seen as types such as:
622+
623+
* ``AnsibleUnicode`` (a subclass of ``str``)
624+
* ``AnsibleSequence`` (a subclass of ``list``)
625+
* ``AnsibleMapping`` (a subclass of ``dict``)
626+
627+
These types, and more, now have new subclasses derived from their native Python types.
628+
In most cases these types behave indistinguishably from the types they extend, and existing code should function normally.
629+
However, some Python libraries do not handle builtin object subclasses properly.
630+
Custom plugins that interact with such libraries may require changes to convert and pass the native types.
631+
632+
.. warning::
633+
This section and the associated public API are currently incomplete.
634+
635+
636+
AnsibleVaultEncryptedUnicode replaced by EncryptedString
637+
--------------------------------------------------------
638+
639+
The ``AnsibleVaultEncryptedUnicode`` type has been replaced by ``EncryptedString``.
640+
641+
Plugins which create ``AnsibleVaultEncryptedUnicode`` will now receive ``EncryptedString`` instances instead.
642+
This feature ensures backward compatibility with previous versions of ``ansible-core``.
643+
644+
Plugins which perform ``isinstance`` checks, looking for ``AnsibleVaultEncryptedUnicode``, will no longer encounter these types.
645+
Values formerly represented by that type will now appear as a tagged ``str`` instead.
646+
Special handling in plugins is no longer required to access the contents of these values.
647+
648+
559649
Command Line
560650
============
561651

@@ -597,6 +687,9 @@ No notable changes
597687
Plugins
598688
=======
599689

690+
Noteworthy plugin changes
691+
-------------------------
692+
600693
* The ``ssh`` connection plugin now supports using ``SSH_ASKPASS`` to supply passwords
601694
for authentication as an alternative to the ``sshpass`` program. The default is to use
602695
``SSH_ASKPASS`` instead of ``sshpass``. This is controlled by the ``password_mechanism``
@@ -622,6 +715,20 @@ Plugins
622715
623716
ansible_ssh_password_mechanism: sshpass
624717
718+
* Coercing unrecognized input values in the ``bool`` filter is deprecated.
719+
The ``bool`` filter now returns only ``True`` or ``False``, depending on the input:
720+
721+
* ``True`` - Returned for ``True``, ``1`` and case-insensitive matches on the strings: "yes", "on", "true", "1"
722+
* ``False`` - Returned for ``False``, ``0`` and case-insensitive matches on the strings: "no", "off", "false", "0"
723+
724+
Any other input will result in a deprecation warning. This warning will become an error in ``ansible-core`` 2.23.
725+
726+
When a deprecation warning is issued, the return value is ``False`` unless the input equals ``1``,
727+
which can occur when the input is the ``float`` value of ``1.0``.
728+
729+
This filter now returns ``False`` instead of ``None`` when the input is ``None``.
730+
The aforementioned deprecation warning is also issued in this case.
731+
625732

626733
Porting custom scripts
627734
======================
@@ -634,6 +741,49 @@ Networking
634741

635742
No notable changes
636743

744+
Porting Guide for v12.0.0a2
745+
===========================
746+
747+
Known Issues
748+
------------
749+
750+
community.general
751+
~~~~~~~~~~~~~~~~~
752+
753+
- reveal_ansible_type filter plugin and ansible_type test plugin - note that ansible-core's Data Tagging feature implements new aliases, such as ``_AnsibleTaggedStr`` for ``str``, ``_AnsibleTaggedInt`` for ``int``, and ``_AnsibleTaggedFloat`` for ``float`` (https://github.com/ansible-collections/community.general/pull/9833).
754+
755+
Major Changes
756+
-------------
757+
758+
grafana.grafana
759+
~~~~~~~~~~~~~~~
760+
761+
- Add tempo role by @CSTDev in https://github.com/grafana/grafana-ansible-collection/pull/323
762+
- Do not log grafana.ini contents when setting facts by @root-expert in https://github.com/grafana/grafana-ansible-collection/pull/325
763+
- Fix loki_operational_config section not getting rendered in config.yml by @olegkaspersky in https://github.com/grafana/grafana-ansible-collection/pull/330
764+
- Fix sectionless items edge case by @santilococo in https://github.com/grafana/grafana-ansible-collection/pull/303
765+
- Fix tags Inherit default vars by @MJurayev in https://github.com/grafana/grafana-ansible-collection/pull/341
766+
- Fix the markdown code fences for install command by @benmatselby in https://github.com/grafana/grafana-ansible-collection/pull/306
767+
- Grafana fix facts in main.yml by @voidquark in https://github.com/grafana/grafana-ansible-collection/pull/315
768+
- Make dashboard imports more flexible by @torfbolt in https://github.com/grafana/grafana-ansible-collection/pull/308
769+
- force temporary directory even in check mode for dashboards.yml by @cmehat in https://github.com/grafana/grafana-ansible-collection/pull/339
770+
- integrate sles legacy init-script support by @floerica in https://github.com/grafana/grafana-ansible-collection/pull/184
771+
- management of the config.river with the conversion of the config.yaml by @lbrule in https://github.com/grafana/grafana-ansible-collection/pull/149
772+
773+
Deprecated Features
774+
-------------------
775+
776+
community.general
777+
~~~~~~~~~~~~~~~~~
778+
779+
- manifold lookup plugin - plugin is deprecated and will be removed in community.general 11.0.0 (https://github.com/ansible-collections/community.general/pull/10028).
780+
- stackpath_compute inventory plugin - plugin is deprecated and will be removed in community.general 11.0.0 (https://github.com/ansible-collections/community.general/pull/10026).
781+
782+
community.vmware
783+
~~~~~~~~~~~~~~~~
784+
785+
- vmware_dvs_portgroup - ``mac_learning`` is deprecated in favour of ``network_policy.mac_learning`` (https://github.com/ansible-collections/community.vmware/pull/2360).
786+
637787
Porting Guide for v12.0.0a1
638788
===========================
639789

@@ -878,6 +1028,8 @@ Ansible-core
8781028
- ``ansible.module_utils.compat.datetime`` - The datetime compatibility shims are now deprecated. They are scheduled to be removed in ``ansible-core`` v2.21. This includes ``UTC``, ``utcfromtimestamp()`` and ``utcnow`` importable from said module (https://github.com/ansible/ansible/pull/81874).
8791029
- bool filter - Support for coercing unrecognized input values (including None) has been deprecated. Consult the filter documentation for acceptable values, or consider use of the ``truthy`` and ``falsy`` tests.
8801030
- cache plugins - The `ansible.plugins.cache.base` Python module is deprecated. Use `ansible.plugins.cache` instead.
1031+
- callback plugins - The `v2_on_any` callback method is deprecated. Use specific callback methods instead.
1032+
- callback plugins - The v1 callback API (callback methods not prefixed with `v2_`) is deprecated. Use `v2_` prefixed methods instead.
8811033
- conditionals - Conditionals using Jinja templating delimiters (e.g., ``{{``, ``{%``) should be rewritten as expressions without delimiters, unless the entire conditional value is a single template that resolves to a trusted string expression. This is useful for dynamic indirection of conditional expressions, but is limited to trusted literal string expressions.
8821034
- config - The ``ACTION_WARNINGS`` config has no effect. It previously disabled command warnings, which have since been removed.
8831035
- config - The ``DEFAULT_JINJA2_NATIVE`` option has no effect. Jinja2 native mode is now the default and only option.

0 commit comments

Comments
 (0)