Hello, when using module ansible.builtin.dnf we try to install packages such as the following on either AIX 7.2 that already have dnf toolbox installed.
Install packages with dnf module from variable PACKAGES (tmux,screen,wget,curl,libssh2,ncat,vim-enhanced,python3-dnf,python3.12)
{
"results": [],
"msg": "Could not import the dnf python module using /opt/freeware/bin/python3 (3.12.12 (main, Oct 14 2025, 02:05:51) [GCC 10.3.0]). Please install `python3-dnf` or `python2-dnf` package or ensure you have specified the correct ansible_python_interpreter. (attempted ['/usr/libexec/platform-python', '/usr/bin/python3', '/usr/bin/python2', '/usr/bin/python'])",
"invocation": {
"module_args": {
"conf_file": "/opt/freeware/etc/dnf/dnf.conf",
"name": [
"tmux",
"screen",
"wget",
"curl",
"libssh2",
"ncat",
"vim-enhanced",
"python3-dnf",
"python3.12"
],
"state": "latest",
"allow_downgrade": false,
"autoremove": false,
"bugfix": false,
"cacheonly": false,
"disable_gpg_check": false,
"disable_plugin": [],
"disablerepo": [],
"download_only": false,
"enable_plugin": [],
"enablerepo": [],
"exclude": [],
"installroot": "/",
"install_repoquery": true,
"install_weak_deps": true,
"security": false,
"skip_broken": false,
"update_cache": false,
"update_only": false,
"validate_certs": true,
"sslverify": true,
"lock_timeout": 30,
"allowerasing": false,
"nobest": false,
"use_backend": "auto",
"disable_excludes": null,
"download_dir": null,
"list": null,
"releasever": null
}
},
"_ansible_no_log": false,
"changed": false
}
root@IFRSAPPDEV / # rpm -qa | grep dnf
libdnf-0.74.0-32_50.ppc
dnf-data-4.23.0-32_51.ppc
python3-dnf-4.23.0-32_51.ppc
dnf-automatic-4.23.0-32_51.ppc
python3.12-libdnf-0.74.0-32_50.ppc
python3-libdnf-0.74.0-32_50.ppc
python3.12-dnf-4.23.0-32_51.ppc
dnf-4.23.0-32_51.ppc
root@IFRSAPPDEV / # /opt/freeware/bin/dnf info python3-dnf
Last metadata expiration check: 4:25:35 ago on January 19, 2026 at 11:25:27 AM EET.
Installed Packages
Name : python3-dnf
Version : 4.23.0
Release : 32_51
Architecture : ppc
Size : 2.0 k
Source : dnf-4.23.0-32_51.src.rpm
Repository : @System
From repo : AIX_Toolbox_72
Summary : Meta package for Python 3 interface to DNF
URL : https://github.com/rpm-software-management/dnf
License : GPLv2+ and GPLv2 and GPL
Description : Meta package for Python 3 interface to DNF.
the yaml that we use:
#---
#- name: Install packages from PACKAGES var
# hosts: all
# gather_facts: true
# become: yes
# vars:
# ansible_python_interpreter: /opt/freeware/bin/python3
# environment:
# PACKAGES: "tmux,screen,wget,curl,ncat,vim-enhanced,python3-dnf,python3.11"
# tasks:
- name: "Install packages with dnf"
block:
- name: "Install packages with dnf module from variable PACKAGES ({{ PACKAGES }})"
ansible.builtin.dnf:
conf_file: /opt/freeware/etc/dnf/dnf.conf
name: "{{ PACKAGES }}"
state: latest
use_backend: "{{ansible_pkg_mgr}}"
vars:
ansible_python_interpreter: "{{ '/opt/freeware/bin/python3' if ansible_distribution_version == '7.3' else '/opt/freeware/libexec/python3.12_32' }}"
rescue:
- name: "Rescue Install packages with shell from variable PACKAGES ({{ PACKAGES }})"
ansible.builtin.shell:
cmd: "{{dnf}} install -y {{ PACKAGES | replace(',',' ') }}"