[Ansible FAQs] The following modules failed to execute: ansible.legacy.setup
The following modules failed to execute: ansible.legacy.setup
Ansible is a powerful tool for automation, but sometimes running it on older systems can present challenges. Recently, while working with servers running Ubuntu 18.04, I encountered issues with the ansible.legacy.setup
module failing to execute. This was primarily due to the outdated Python versions on these servers, which are not supported by the latest versions of Ansible.
Ubuntu 18.04, being an older distribution, does not appear in the Ubuntu Python 3 packages page. The core of the problem lies in the compatibility between the Python versions on these older servers and the Ansible versions being deployed.
Understanding Ansible’s Python Support
Ansible’s compatibility with different Python versions has evolved over time. As of the latest updates, Ansible no longer supports Python 2.7 in its more recent releases. Here’s a brief overview of Ansible’s Python support based on its core versions:
Ansible Community Package Release | Status | Core version dependency |
---|---|---|
11.0.0 | In development (unreleased) | 2.18 |
10.x | Current | 2.17 |
9.x | Minor/patch releases (EOL Nov 2024) | 2.16 |
8.x | Unmaintained (end of life) | 2.15 |
7.x | Unmaintained (end of life) | 2.14 |
6.x | Unmaintained (end of life) | 2.13 |
5.x | Unmaintained (end of life) | 2.12 |
4.x | Unmaintained (end of life) | 2.11 |
3.x | Unmaintained (end of life) | 2.10 |
2.10 | Unmaintained (end of life) | 2.10 |
For detailed changelogs, you can refer to the Ansible Community Documentation.
ansible-core
support matrix
This table links to the changelogs for each major ansible-core
release. These changelogs contain the dates and significant changes in each minor release. Dates listed indicate the start date of the maintenance cycle.
Version | Support | End Of Life | Control Node Python | Target Python / PowerShell |
---|---|---|---|---|
2.17 | GA: 20 May 2024 Critical: 04 Nov 2024 Security: 19 May 2025 |
Nov 2025 | Python 3.10 - 3.12 | Python 3.7 - 3.12 PowerShell 5.1 |
2.16 | GA: 06 Nov 2023 Critical: 20 May 2024 Security: Nov 2024 |
May 2025 | Python 3.10 - 3.12 | Python 2.7 Python 3.6 - 3.12 Powershell 5.1 |
2.15 | GA: 22 May 2023 Critical: 06 Nov 2023 Security: 20 May 2024 |
Nov 2024 | Python 3.9 - 3.11 | Python 2.7 Python 3.5 - 3.11 PowerShell 3 - 5.1 |
2.14 | GA: 07 Nov 2022 Critical: 22 May 2023 Security: 06 Nov 2023 |
EOL 20 May 2024 |
Python 3.9 - 3.11 | Python 2.7 Python 3.5 - 3.11 PowerShell 3 - 5.1 |
2.13 | GA: 23 May 2022 Critical: 07 Nov 2022 Security: 22 May 2023 |
EOL 06 Nov 2023 |
Python 3.8 - 3.10 | Python 2.7 Python 3.5 - 3.10 PowerShell 3 - 5.1 |
2.12 | GA: 08 Nov 2021 Critical: 23 May 2022 Security: 07 Nov 2022 |
EOL 22 May 2023 |
Python 3.8 - 3.10 | Python 2.6 - 2.7 Python 3.5 - 3.10 PowerShell 3 - 5.1 |
2.11 | GA: 26 Apr 2021 Critical: 08 Nov 2021 Security: 23 May 2022 |
EOL 07 Nov 2022 |
Python 2.7 Python 3.5 - 3.9 |
Python 2.6 - 2.7 Python 3.5 - 3.9 PowerShell 3 - 5.1 |
2.10 | GA: 13 Aug 2020 Critical: 26 Apr 2021 Security: 08 Nov 2021 |
EOL 23 May 2022 |
Python 2.7 Python 3.5 - 3.9 |
Python 2.6 - 2.7 Python 3.5 - 3.9 PowerShell 3 - 5.1 |
2.9 | GA: 31 Oct 2019 Critical: 13 Aug 2020 Security: 26 Apr 2021 |
EOL 23 May 2022 |
Python 2.7 Python 3.5 - 3.8 |
Python 2.6 - 2.7 Python 3.5 - 3.8 PowerShell 3 - 5.1 |
Addressing Compatibility Issues
To address compatibility issues on Ubuntu 18.04 servers, you can install an older version of Ansible that still supports Python 2.7. As per the documentation, ansible-core
version 2.16 and earlier include support for Python 2.7. The recommended approach is to use Ansible 9.7.0, which is compatible with these older Python versions.
Installing Ansible 9.7.0
To install Ansible 9.7.0, use the following pip command:
1 | pip install ansible==9.7.0 |
This ensures that your Ansible setup is compatible with the Python version available on Ubuntu 18.04 servers, allowing you to execute playbooks and modules without encountering the ansible.legacy.setup
module failure.
Conclusion
Running Ansible on older servers requires careful consideration of Python version compatibility. By aligning your Ansible version with the supported Python versions on your target nodes, you can avoid execution failures and maintain smooth automation workflows. Keeping track of Ansible’s release notes and compatibility tables will help you make informed decisions and ensure your automation infrastructure remains robust and efficient.