Description of problem: Fedora 30 obsoleted the package python2-dnf. When the module package or dnf is used, it wants to run the command dnf install -y python2-dnf. This fails since this package is not present anymore. This should point to python3-dnf. Solution provided at the bottom. Version-Release number of selected component (if applicable): ansible 2.7.9 config file = /home/user/git/ansible/ansible.cfg configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] ansible python module location = /usr/lib/python3.7/site-packages/ansible executable location = /usr/bin/ansible python version = 3.7.2 (default, Mar 21 2019, 10:09:12) [GCC 8.3.1 20190223 (Red Hat 8.3.1-2)] How reproducible: $ ansible --vault-id @prompt defiant -m dnf -a "name=vim state=present" -vv defiant | FAILED! => { "changed": false, "cmd": "dnf install -y python2-dnf", "msg": "Error: Unable to find a match", "rc": 1, "stderr": "Error: Unable to find a match\n", "stderr_lines": [ "Error: Unable to find a match" ], "stdout": "Last metadata expiration check: 0:02:19 ago on do 04 apr 2019 15:00:35 CEST.\nNo match for argument: python2-dnf\n", "stdout_lines": [ "Last metadata expiration check: 0:02:19 ago on do 04 apr 2019 15:00:35 CEST.", "No match for argument: python2-dnf" ] } Additional info: Ansible 2.7 still defaults to executing /usr/bin/python which would point to python2. You would have to explicitly set ansible_python_interpreter=/usr/bin/python3 to use Python3. The dnf module selects the appropriate dnf python bindings package that needs installed based on the version of python that is being executed on the remote side.
For Fedora30+ machines (or any machines where python3 is installed and python2 is not) you should tell ansible to use python3 for that target: https://docs.ansible.com/ansible/latest/reference_appendices/python_3_support.html In an upcoming ansible release, ansible may be able to auto detect what python you want to use, but thats not currently implemented. I don't think there's much we can do here...
Yeah, this is working as designed in Ansible-2.7. Ansible-2.8+ will have a feature that you can turn on to autodetect the python interpreter to use on the remote machine: https://docs.ansible.com/ansible/devel/reference_appendices/interpreter_discovery.html The convenience comes at the cost of having to make additional round trips to the server. Depending on your network latency, it might be worthwhile to continue to set ansible_python_interpreter explicitly. I've tested that the feature chooses /usr/bin/python3 on Fedora 29 with multiple versions of python installed from the versioned python rpms. There could be bugs in other configurations, though, (for instance locally installing python from source or changing what /usr/bin/python3 refers to, or other platforms than Fedora) as there are a multitude of different scenarios out there.
Ran into a similar issue with RHEL 7.7 Server. My issue is there doesn't appear to be a python3-dnf listed in the repository. Thoughts/ideas?