|
| 1 | + |
| 2 | +.. _porting_2.20_guide_core: |
| 3 | + |
| 4 | +******************************* |
| 5 | +Ansible-core 2.20 Porting Guide |
| 6 | +******************************* |
| 7 | + |
| 8 | +This section discusses the behavioral changes between ``ansible-core`` 2.19 and ``ansible-core`` 2.20. |
| 9 | + |
| 10 | +It is intended to assist in updating your playbooks, plugins, |
| 11 | +and other parts of your Ansible infrastructure so they will work with this version of Ansible. |
| 12 | + |
| 13 | +Review this page and the |
| 14 | +`ansible-core Changelog for 2.20 <https://github.com/ansible/ansible/blob/stable-2.20/changelogs/CHANGELOG-v2.20.rst>`_ |
| 15 | +to understand necessary changes. |
| 16 | + |
| 17 | +This document is part of a collection on porting. |
| 18 | +The complete list of porting guides can be found at :ref:`porting guides <porting_guides>`. |
| 19 | + |
| 20 | +.. contents:: Topics |
| 21 | + |
| 22 | +.. _2.20_introduction: |
| 23 | + |
| 24 | +Introduction |
| 25 | +============ |
| 26 | + |
| 27 | +No notable changes |
| 28 | + |
| 29 | +.. _2.20_playbook: |
| 30 | + |
| 31 | +Playbook |
| 32 | +======== |
| 33 | + |
| 34 | +Removed quote stripping in PowerShell operations |
| 35 | +------------------------------------------------- |
| 36 | + |
| 37 | +The PowerShell module utilities no longer attempt to remove quotes from paths when performing Windows operations like copying and fetching files. This should not affect normal playbooks unless a value is quoted too many times. If you have playbooks that rely on this automatic quote removal, you will need to adjust your path formatting. |
| 38 | + |
| 39 | +.. _2.20_engine: |
| 40 | + |
| 41 | +Engine |
| 42 | +====== |
| 43 | + |
| 44 | +No notable changes |
| 45 | + |
| 46 | +.. _2.20_plugin_api: |
| 47 | + |
| 48 | +Plugin API |
| 49 | +========== |
| 50 | + |
| 51 | +Removed Features |
| 52 | +---------------- |
| 53 | + |
| 54 | +The following previously deprecated features have been removed: |
| 55 | + |
| 56 | +* The ``DEFAULT_TRANSPORT`` configuration option no longer supports the ``smart`` value that selected the default transport as either ``ssh`` or ``paramiko`` based on the underlying platform configuration. |
| 57 | +* The ``vault`` and ``unvault`` filters no longer accept the deprecated ``vaultid`` parameter. |
| 58 | +* The ``ansible-galaxy`` command no longer supports the v2 Galaxy server API. Galaxy servers hosting collections must support v3. |
| 59 | +* The ``dnf`` and ``dnf5`` modules no longer support the deprecated ``install_repoquery`` option. |
| 60 | +* The ``encrypt`` module utility no longer includes the deprecated ``passlib_or_crypt`` API. |
| 61 | +* The ``paramiko`` connection plugin no longer supports the ``PARAMIKO_HOST_KEY_AUTO_ADD`` and ``PARAMIKO_LOOK_FOR_KEYS`` configuration keys, which were previously deprecated. |
| 62 | +* The ``py3compat.environ`` call has been removed. |
| 63 | +* Vars plugins that do not inherit from ``BaseVarsPlugin`` and define a ``get_vars`` method can no longer use the deprecated ``get_host_vars`` or ``get_group_vars`` fallback. |
| 64 | +* The ``yum_repository`` module no longer supports the deprecated ``keepcache`` option. |
| 65 | + |
| 66 | +Behavioral Changes |
| 67 | +------------------ |
| 68 | + |
| 69 | +* The ``DataLoader.get_basedir`` method now returns an absolute path instead of a relative path. Plugin code that relies on relative paths may need adjustment. |
| 70 | +* Argument spec validation now treats ``None`` values as empty strings for the ``str`` type for better consistency with pre-2.19 templating conversions. |
| 71 | +* When using ``failed_when`` to suppress an error, the ``exception`` key in the result is now renamed to ``failed_when_suppressed_exception``. This prevents the error from being displayed by callbacks after being suppressed. If you have playbooks that check for the exception in the result, update them as follows: |
| 72 | + |
| 73 | +.. code-block:: yaml+jinja |
| 74 | + |
| 75 | + # Before |
| 76 | + - command: /bin/false |
| 77 | + register: result |
| 78 | + failed_when: false |
| 79 | + |
| 80 | + - debug: |
| 81 | + msg: "Exception was: {{ result.exception }}" |
| 82 | + when: result.exception is defined |
| 83 | + |
| 84 | + # After |
| 85 | + - command: /bin/false |
| 86 | + register: result |
| 87 | + failed_when: false |
| 88 | + |
| 89 | + - debug: |
| 90 | + msg: "Exception was: {{ result.failed_when_suppressed_exception }}" |
| 91 | + when: result.failed_when_suppressed_exception is defined |
| 92 | + |
| 93 | +.. _2.20_command_line: |
| 94 | + |
| 95 | +Command Line |
| 96 | +============ |
| 97 | + |
| 98 | +* Python 3.11 is no longer a supported control node version. Python 3.12+ is now required for running Ansible. |
| 99 | +* Python 3.8 is no longer a supported remote version. Python 3.9+ is now required for target execution. |
| 100 | + |
| 101 | +.. _2.20_deprecated: |
| 102 | + |
| 103 | +Deprecated |
| 104 | +========== |
| 105 | + |
| 106 | +INJECT_FACTS_AS_VARS |
| 107 | +-------------------- |
| 108 | + |
| 109 | +The ``INJECT_FACTS_AS_VARS`` configuration currently defaults to ``True``, but this is now deprecated and it will switch to ``False`` in Ansible 2.24. |
| 110 | + |
| 111 | +When enabled, facts are available both inside the ``ansible_facts`` dictionary and as individual variables in the main namespace. In the ``ansible_facts`` dictionary, the ``ansible_`` prefix is removed from fact names. |
| 112 | + |
| 113 | +You will receive deprecation warnings if you are accessing 'injected' facts. To prepare for the future default: |
| 114 | + |
| 115 | +**Update your playbooks to use the ansible_facts dictionary:** |
| 116 | + |
| 117 | +.. code-block:: yaml+jinja |
| 118 | + |
| 119 | + # Deprecated - will stop working in 2.24 |
| 120 | + - debug: |
| 121 | + msg: "OS: {{ ansible_os_distribution }}" |
| 122 | + |
| 123 | + # Recommended - works in all versions |
| 124 | + - debug: |
| 125 | + msg: "OS: {{ ansible_facts['distribution'] }}" |
| 126 | + # Note: 'ansible_' prefix is removed inside ansible_facts |
| 127 | + |
| 128 | +**Or explicitly enable the current behavior in your configuration:** |
| 129 | + |
| 130 | +In your ``ansible.cfg`` file: |
| 131 | + |
| 132 | +.. code-block:: ini |
| 133 | +
|
| 134 | + [defaults] |
| 135 | + inject_facts_as_vars = True |
| 136 | +
|
| 137 | +By exporting an environment variable: |
| 138 | + |
| 139 | +.. code-block:: shell |
| 140 | +
|
| 141 | + export ANSIBLE_INJECT_FACT_VARS=True |
| 142 | +
|
| 143 | +Other Deprecations |
| 144 | +------------------ |
| 145 | + |
| 146 | +* The ``vars`` internal variable cache will be removed in 2.24. This cache, once used internally, exposes variables in inconsistent states. The ``vars`` and ``varnames`` lookups should be used instead. |
| 147 | +* Specifying ``ignore_files`` as a string in the ``include_vars`` module is deprecated. Use a list instead: |
| 148 | + |
| 149 | +.. code-block:: yaml |
| 150 | +
|
| 151 | + # Deprecated |
| 152 | + - include_vars: |
| 153 | + dir: vars/ |
| 154 | + ignore_files: ".gitkeep" |
| 155 | +
|
| 156 | + # Correct |
| 157 | + - include_vars: |
| 158 | + dir: vars/ |
| 159 | + ignore_files: [".gitkeep"] |
| 160 | +
|
| 161 | +.. _2.20_modules: |
| 162 | + |
| 163 | +Modules |
| 164 | +======= |
| 165 | + |
| 166 | +Modules removed |
| 167 | +--------------- |
| 168 | + |
| 169 | +The following modules no longer exist: |
| 170 | + |
| 171 | +* No notable changes |
| 172 | + |
| 173 | +Deprecation notices |
| 174 | +------------------- |
| 175 | + |
| 176 | +No notable changes |
| 177 | + |
| 178 | +Noteworthy module changes |
| 179 | +------------------------- |
| 180 | + |
| 181 | +* The ``include_vars`` module now raises an error if the ``extensions`` parameter is not specified as a list. Previously, non-list values were silently accepted. |
| 182 | +* The ``include_vars`` module now raises an error if the ``ignore_files`` parameter is not specified as a list. Previously, string values were accepted but are now deprecated. |
| 183 | +* The ``replace`` module now reads and writes files in text-mode as unicode characters instead of as bytes, and switches regex matching to unicode characters instead of bytes. This may affect playbooks that rely on byte-level operations. |
| 184 | + |
| 185 | +Plugins |
| 186 | +======= |
| 187 | + |
| 188 | +Noteworthy plugin changes |
| 189 | +------------------------- |
| 190 | + |
| 191 | +No notable changes |
| 192 | + |
| 193 | +Porting custom scripts |
| 194 | +====================== |
| 195 | + |
| 196 | +No notable changes |
| 197 | + |
| 198 | +Networking |
| 199 | +========== |
| 200 | + |
| 201 | +No notable changes |
0 commit comments