This section discusses the behavioral changes between Ansible 2.7 and Ansible 2.8.
It is intended to assist in updating your playbooks, plugins and other parts of your Ansible infrastructure so they will work with this version of Ansible.
We suggest you read this page along with Ansible Changelog for 2.8 to understand what updates you may need to make.
This document is part of a collection on porting. The complete list of porting guides can be found at porting guides.
The information returned for the
ansible_distribution_* group of facts may have changed
slightly. Ansible 2.8 uses a new backend library for information about distributions: nir0s/distro. This library runs on Python-3.8 and fixes many bugs, including correcting release and version names.
The two facts used in playbooks most often,
ansible_distribution_major_version, should not change. If you discover a change in these facts, please file a bug so we can address the
difference. However, other facts like
ansible_distribution_version may change as erroneous information gets corrected.
Beginning in version 2.8, by default Ansible will use the word
BECOME to prompt you for a password for elevated privileges (
sudo privileges on unix systems or
enable mode on network devices):
By default in Ansible 2.8:
ansible-playbook --become --ask-become-pass site.yml BECOME password:
If you want the prompt to display the specific
become_method you’re using, instead of the agnostic value
BECOME, set AGNOSTIC_BECOME_PROMPT to
False in your Ansible configuration.
By default in Ansible 2.7, or with
AGNOSTIC_BECOME_PROMPT=False in Ansible 2.8:
ansible-playbook --become --ask-become-pass site.yml SUDO password:
Setting the async directory using
ANSIBLE_ASYNC_DIR as an task/play environment key is deprecated and will be
removed in Ansible 2.12. You can achieve the same result by setting
ansible_async_dir as a variable like:
- name: run task with custom async directory command: sleep 5 async: 10 vars: ansible_aync_dir: /tmp/.ansible_async
Plugin writers who need a
FactCache object should be aware of two deprecations:
FactCacheclass has moved from
ansible.vars.fact_cache.FactCache. This is because the
FactCacheis not part of the cache plugin API and cache plugin authors should not be subclassing it.
FactCacheis still available from its old location but will issue a deprecation warning when used from there. The old location will be removed in Ansible 2.12.
FactCache.update()method has been converted to follow the dict API. It now takes a dictionary as its sole argument and updates itself with the dictionary’s items. The previous API where
update()took a key and a value will now issue a deprecation warning and will be removed in 2.12. If you need the old behaviour switch to
Major changes in popular modules are detailed here
The exec wrapper that runs PowerShell modules has been changed to set
$ErrorActionPreference = "Stop" globally.
This may mean that custom modules can fail if they implicitly relied on this behaviour. To get the old behaviour back,
$ErrorActionPreference = "Continue" to the top of the module. This change was made to restore the old behaviour
of the EAP that was accidentally removed in a previous release and ensure that modules are more resiliant to errors
that may occur in execution.
The following modules no longer exist:
The following modules will be removed in Ansible 2.12. Please update your playbooks accordingly.
foremanuse <https://github.com/theforeman/foreman-ansible-modules> instead.
katellouse <https://github.com/theforeman/foreman-ansible-modules> instead.
github_hooksuse github_webhook and github_webhook_facts instead.
katellomodules have been deprecated in favor of a set of modules that are broken out per entity with better idempotency in mind.
katellomodules replacement is officially part of the Foreman Community and supported there.
tower_credentialmodule originally required the
ssh_key_datato be the path to a ssh_key_file. In order to work like Tower/AWX,
ssh_key_datanow contains the content of the file. The previous behavior can be achieved with
win_scheduled_taskmodule deprecated support for specifying a trigger repetition as a list and this format will be removed in Ansible 2.12. Instead specify the repetition as a dictionary value.
win_featuremodule has removed the deprecated
restart_neededreturn value, use the standardised
win_packagemodule has removed the deprecated
exit_codereturn value, use the standardised
win_get_urlmodule has removed the deprecated
win_get_urlreturn dictionary, contained values are returned directly.
win_get_urlmodule has removed the deprecated
skip_certificate_validationoption, use the standardised
vmware_local_role_factsmodule now returns a list of dicts instead of a dict of dicts for role information.
docker_volumewere called with
debug: yes, a return value called
diffwas returned of type
list. To enable proper diff output, this was changed to type
dict; the original
listis returned as
na_ontap_cluster_peermodule has replaced
dest_intercluster_lifstring options with
modprobemodule now detects kernel builtins. Previously, attempting to remove (with
state: absent) a builtin kernel module succeeded without any error message because
modprobedid not detect the module as
modprobewill fail if a kernel module is builtin and
state: absent(with an error message from the modprobe binary like
modprobe: ERROR: Module nfs is builtin.), and it will succeed without reporting changed if
state: present. Any playbooks that are using
changed_when: noto mask this quirk can safely remove that workaround. To get the previous behavior when applying
state: absentto a builtin kernel module, use
ignore_errors: truein your playbook.
powershell shell plugin now uses
async_dir to define the async path for the results file and the default
has changed to
%USERPROFILE%\.ansible_async. To control this path now, either set the
variable or the
async_dir value in the
powershell section of the config ini.
_options attribute has been removed from the
CallbackBase class of callback
plugins. If you have a third-party callback plugin which needs to access the command line arguments,
use code like the following instead of trying to use
from ansible import context [...] tags = context.CLIARGS['tags']
context.CLIARGS is a read-only dictionary so normal dictionary retrieval methods like
CLIARGS['tags'] work as expected but you won’t be able to modify
the cli arguments at all.
As of Ansible 2.8, the
Display class is now a “singleton”. Instead of using
__main__.display each file should
import and instantiate
ansible.utils.display.Display on its own.
OLD In Ansible 2.7 (and earlier) the following was used to access the
try: from __main__ import display except ImportError: from ansible.utils.display import Display display = Display()
NEW In Ansible 2.8 the following should be used:
from ansible.utils.display import Display display = Display()