Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python2_dnf is not available for Fedora 30 (rawhide) #49362

Closed
robertdebock opened this issue Nov 30, 2018 · 6 comments
Closed

python2_dnf is not available for Fedora 30 (rawhide) #49362

robertdebock opened this issue Nov 30, 2018 · 6 comments
Assignees
Labels
affects_2.7 This issue/PR affects Ansible v2.7 bug This issue/PR relates to a bug. module This issue/PR relates to a module. python3 support:core This issue/PR relates to code supported by the Ansible Engineering Team.

Comments

@robertdebock
Copy link
Contributor

SUMMARY

Fedora 30 (now rawhide, the unreleased development branch) will not offer python2-dnf anymore.

This causes a problem when installing python2 on Fedora 30.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

dnf

ANSIBLE VERSION
ansible 2.7.1
  config file = None
  configured module search path = [u'/home/robertdb/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.15 (default, Oct 15 2018, 15:26:09) [GCC 8.2.1 20180801 (Red Hat 8.2.1-2)]
CONFIGURATION
[no output]
OS / ENVIRONMENT

Control node does not matter, I'm using Fedora 29.
Managed node: Fedora 30/rawhide

STEPS TO REPRODUCE

Start a fedora rawhide container:

docker run --rm fedora:rawhide sleep 300

Install python2 on it:

ansible \
  -m dnf \
  -a "name=python2" \
  -i f9f2e079d337, \
  -c docker \
  -e "ansible_python_interpreter=/usr/bin/python3" \
  all

Install another package using the default ansible_python_interpreter:

ansible \
  -m dnf \
  -a "name=sos" \
  -i f9f2e079d337, \
  -c docker \
  all

Another way to test this: (could be used in the integration tests)

# INSTALLPYTHON2
#  The module `dnf` tries to install python2-dnf when it's running on systems
#  that have python2 installed. Fedora 30 and newer have python3 and limited
#  support for python2, for example python2-dnf is missing.

- name: use python3
  set_fact:
    ansible_python_interpreter: /usr/bin/python3

- name: install python2
  dnf:
    name: python2
    state: present

- name: use python2
  set_fact:
    ansible_python_interpreter: /usr/bin/python

- name: install a sample package
  dnf:
    name: python2
    state: present
EXPECTED RESULTS

Just to have python2 installed, I'm not interested in python2-dnf.

I realize this an edge case, and fixing it may cause more issues, like #22305.

ACTUAL RESULTS
f9f2e079d337 | 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:01:03 ago on Fri Nov 30 10:19:16 2018.\nNo match for argument: python2-dnf\n", 
    "stdout_lines": [
        "Last metadata expiration check: 0:01:03 ago on Fri Nov 30 10:19:16 2018.", 
        "No match for argument: python2-dnf"
    ]
}
@ansibot
Copy link
Contributor

ansibot commented Nov 30, 2018

Hi @robertdebock, thank you for submitting this issue!

click here for bot help

@ansibot
Copy link
Contributor

ansibot commented Nov 30, 2018

Files identified in the description:

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibot ansibot added affects_2.7 This issue/PR affects Ansible v2.7 bug This issue/PR relates to a bug. module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. python3 support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Nov 30, 2018
@sivel sivel removed the needs_triage Needs a first human triage before being processed. label Dec 4, 2018
@ansibot ansibot closed this as completed in 3247eec Dec 4, 2018
@maxamillion
Copy link
Contributor

Ultimately I think the issue here is that Fedora is moving away from python2 and there's nothing Ansible can realistically do.

@maxamillion maxamillion reopened this Dec 5, 2018
@ansibot
Copy link
Contributor

ansibot commented Dec 5, 2018

jborean93 added a commit to jborean93/ansible that referenced this issue Dec 6, 2018
kbreit pushed a commit to kbreit/ansible that referenced this issue Jan 11, 2019
…ython2-dnf. (ansible#49402)

* Create python3and2

Adding tests to see if dnf still works when python-2 and python-3 are installed.

* Update main.yml

Include the tests that run on python 2 and python 3, based on the package manager.

* Update dnf.py

Use python3-dnf by default, otherwise python2-dnf.

* Rename python3and2 to python3and2.yml

Rename.
kbreit pushed a commit to kbreit/ansible that referenced this issue Jan 11, 2019
@imp1sh
Copy link

imp1sh commented Jul 20, 2019

Ultimately I think the issue here is that Fedora is moving away from python2 and there's nothing Ansible can realistically do.

Python2 is loosing support next year so everybody is being forced to drop python2 support for everything. Why not just install python3-dnf instead of python2-dnf?
In my case I'm not even trying to install anything python2 related but only try to use the dnf module which seems to rely on python2_dnf which I think is wrong.

@jborean93
Copy link
Contributor

@imp1sh the problem is that you are trying to run the dnf module with /use/bin/python which is Python 2. The module just checks on the Python version that is currently running and if it’s Python 2 it will attempt to install python2-dnf which is no longer available in recent Fedora versions.

The dnf module can’t change interpreters as it is not in charge of that proves so you must do it yourself by either;

  • Set the interpreter explicitly to the Python interpreter you want with the var ansible_python_interpreter: /use/bin/python3, or
  • Opt out of the legacy behaviour and get Ansible to dynamically choose the best Python interpreter for the district with ansible_python_interpreter: auto

The latter option will be the new default in Ansible 2.12 but because it is a change in behaviour we had to have a deprecation period since it was introduced in Ansible 2.8. You can read more about python interpreter discovery here.

@ansible ansible locked and limited conversation to collaborators Jul 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.7 This issue/PR affects Ansible v2.7 bug This issue/PR relates to a bug. module This issue/PR relates to a module. python3 support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
None yet
Development

No branches or pull requests

6 participants