Bug 2203513

Summary: ansible_community.general.copr fails using the new RHEL 9.2
Product: [Fedora] Fedora EPEL Reporter: David <gigabot>
Component: ansible-collection-community-generalAssignee: Maxwell G <maxwell>
Status: CLOSED ERRATA QA Contact:
Severity: urgent Docs Contact:
Priority: unspecified    
Version: epel9CC: infra-sig, maxwell
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: ansible-collection-community-general-4.8.11-1.el9 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-05-24 01:51:05 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description David 2023-05-13 13:46:40 UTC
My Ansible script worked until I updated to RHEL 9.2 today, now from the following line of the script:

```
- name: Add the el9 Lazygit repository
          community.general.copr:
            name: atim/lazygit
            chroot: "epel-9-{{ ansible_architecture }}"
```

I get (lappy is my laptop's name):

```
The full traceback is:
Traceback (most recent call last):
  File "/tmp/ansible_community.general.copr_payload_q9bqhct1/ansible_community.general.copr_payload.zip/ansible_collections/community/general/plugins/modules/copr.py", line 81, in <module>
ModuleNotFoundError: No module named 'dnf'
fatal: [localhost]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "chroot": "epel-9-x86_64",
            "host": "copr.fedorainfracloud.org",
            "name": "atim/lazygit",
            "protocol": "https",
            "state": "enabled"
        }
    },
    "msg": "Failed to import the required Python library (dnf) on lappy's Python /usr/bin/python3.11. Please read the module documentation and install it in the appropriate location. If the required library is installed, but Ansible is using the wrong Python interpreter, please consult the documentation on ansible_python_interpreter"
}
```

`ansible-collection-community-general` is stuck on version 4.8.9, why not update it to the latest version 7? That might cure this problem, and a large number of other bugs that have been fixed.

Comment 1 Maxwell G 2023-05-13 18:15:47 UTC
> `ansible-collection-community-general` is stuck on version 4.8.9, why not update it to the latest version 7? That might cure this problem, and a large number of other bugs that have been fixed.

This is the not the culprit of the issue, but I am planning to update to version 7 prior to the releases of RHEL 8.9 and 9.3. The problem here is that ansible-core in RHEL 9.2 is packaged for python3.11 instead of the system python3 (3.9) python interpreter[0]. The dnf module is only available for the system interpreter. I have submitted an upstream PR to community.general to make the copr module "respawn" itself to the correct interpreter if `ansible_python_interpreter` is not the default system interpreter[1]. `ansible_python_interpreter` is the Python interpreter that ansible uses to run modules on the target system. When running against localhost, this may or may not be the same interpreter used to run the ansible controller. In the meantime, you can add `localhost` to your ansible inventory [2] instead of using implicit localhost [3] so ansible will run interpreter discovery [4] and set `ansible_python_interpreter` to `/usr/bin/python3`. Alternatively, you can set the `ansible_python_interpreter` var to `/usr/bin/python3` yourself.

[0] https://lists.fedoraproject.org/archives/list/epel-devel@lists.fedoraproject.org/thread/2MAGEGNYTGIPQLMYDJHNS2E5MQ5P35XD/
[1] https://github.com/ansible-collections/community.general/pull/6522
[2] https://docs.ansible.com/ansible/latest/inventory_guide/intro_inventory.html
[3] https://docs.ansible.com/ansible/latest/inventory/implicit_localhost.html
[4] https://docs.ansible.com/ansible/devel/reference_appendices/interpreter_discovery.html

Comment 2 Fedora Update System 2023-05-14 02:07:26 UTC
FEDORA-EPEL-2023-1d7558ca69 has been submitted as an update to Fedora EPEL 9. https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2023-1d7558ca69

Comment 3 David 2023-05-14 10:03:35 UTC
Thanks for addressing this so quickly!

Comment 4 Fedora Update System 2023-05-15 02:23:41 UTC
FEDORA-EPEL-2023-1d7558ca69 has been pushed to the Fedora EPEL 9 testing repository.

You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2023-1d7558ca69

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 5 Fedora Update System 2023-05-24 01:51:05 UTC
FEDORA-EPEL-2023-1d7558ca69 has been pushed to the Fedora EPEL 9 stable repository.
If problem still persists, please make note of it in this bug report.