Import gi - Fedora linux-system-roles.network

Error from AWX is driving me crazy.
The error occurs here.

TASK [fedora.linux_system_roles.network : Configure networking connection profiles] ***
task path: /usr/share/ansible/collections/ansible_collections/fedora/linux_system_roles/roles/network/tasks/main.yml:159
The full traceback is:

The last line of the traceback points to this →

"exception: Traceback (most recent call last):\n  File \"/tmp/ansible_fedora.linux_system_roles.network_connections_payload_s7jm1p6r/ansible_fedora.linux_system_roles.network_connections_payload.zip/ansible_collections/fedora/linux_system_roles/plugins/modules/network_connections.py\", line 2853, in main\n  File \"/tmp/ansible_fedora.linux_system_roles.network_connections_payload_s7jm1p6r/ansible_fedora.linux_system_roles.network_connections_payload.zip/ansible_collections/fedora/linux_system_roles/plugins/modules/network_connections.py\", line 2079, in run\n  File \"/tmp/ansible_fedora.linux_system_roles.network_connections_payload_s7jm1p6r/ansible_fedora.linux_system_roles.network_connections_payload.zip/ansible_collections/fedora/linux_system_roles/plugins/module_utils/network_lsr/argument_validator.py\", line 2535, in validate_connection_one\n    if not hasattr(Util.NM(), \"SETTING_IP6_CONFIG_METHOD_DISABLED\"):\n                   ^^^^^^^^^\n  File \"/tmp/ansible_fedora.linux_system_roles.network_connections_payload_s7jm1p6r/ansible_fedora.linux_system_roles.network_connections_payload.zip/ansible_collections/fedora/linux_system_roles/plugins/module_utils/network_lsr/utils.py\", line 68, in NM\n    import gi\nModuleNotFoundError: No module named 'gi'\n"

I can exec a shell in the ee image, run python3.11 in the shell, and import the gi module. What is causing this problem?

Ansible info

[root@b2c6b13514f4 runner]# ansible --version
ansible [core 2.17.4]
  config file = None
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.11/site-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.11.10 (main, Sep  9 2024, 00:00:00) [GCC 14.2.1 20240801 (Red Hat 14.2.1-1)] (/usr/bin/python3.11)
  jinja version = 3.1.4
  libyaml = True

Collection info ( abbreviated )

# /usr/local/lib/python3.11/site-packages/ansible_collections
Collection                               Version
---------------------------------------- -------
amazon.aws                               8.2.1
ansible.netcommon                        6.1.3
ansible.posix                            1.5.4
ansible.utils                            4.1.

# /usr/share/ansible/collections/ansible_collections
Collection                               Version
---------------------------------------- -------
fedora.linux_system_roles                1.88.9

The base image is defined as

version: 3

images:
  base_image:
    name: registry.fedoraproject.org/fedora:40

and

dependencies:
  ansible_core:
    package_pip: ansible
  ansible_runner:
    package_pip: ansible-runner
  python_interpreter:
    package_system: "python3.11"
    python_path: "/usr/bin/python3.11"
  galaxy: requirements.yml
  python: requirements.txt
  system:
    - python3.11-devel [platform:rpm]
    - adcli [platform:rpm]
    - gcc [platform:rpm]
    - cmake [platform:rpm]
    - cairo-devel [platform:rpm]
    - git-core [platform:rpm]
    - git-lfs [platform:rpm]
    - krb5-devel [platform:rpm compile]
    - krb5-workstation [platform:rpm]
    - libcurl-devel [platform:rpm compile]
    - python3.11-devel [platform:rpm compile]
    - rsync [platform:rpm]
    - sshpass [platform:rpm]
    - subversion [platform:dpkg]
    - subversion [platform:rpm]
    - unzip [platform:rpm]
    - python3-gobject [platform:rpm]
    - python3-pexpect [platform:rpm]
    - python3-cairo [platform:rpm]
    - openldap-clients [platform:rpm]
    - gobject-introspection [platform:rpm]
    - gobject-introspection-devel [platform:rpm]
    - cairo-gobject-devel [platform:rpm]
    - pkg-config [platform:rpm]

gi isn’t needed in the EE, it’s needed on the target host being configured.

Thanks for the response. Sorry for the dumb question, but what part of the error gave that away for you?

It really looks like it’s complaining about the module in the collection?

The python interpreter is set to auto in the ansible config. We don’t set up python3.11 on our RHEL 8 hosts. I guess we need to set alternatives for python3 to point to 3.11 on the RHEL 9 systems?

Modules, specifically those that configure things, are rarely used in the context of targeting the EE because that isn’t useful. The deps for those modules are required on the target system, since that is where the module actually executes. This is just a description of the standard model of execution of modules.

You may or may not want to target python3.11 on RHEL9 because likely the deps for the modules from the linux_system_roles, are likely not published for anything other than the default system python of 3.9.

1 Like

Well, again, thanks for the explanation. I’m still re-reading your explanation and going back to basic docs to try and adjust my mental model of what’s happening sorted out. I’ve been using Ansible for eight or nine? years now and have not had to re-evaluate or dig this deeply into the basics to figure out what has always ‘just worked’.