Skip to content

Python incompatibilty with RHEL 7 #299

Open
@acch

Description

@acch

When defining the variable state: absent (on a per-host basis), and running the project against a RHEL 7 node, I get the following error:

No module named request
Traceback (most recent call last):
  File \"/root/.ansible/tmp/ansible-tmp-1605877443.8632338-520263-221689487663112/AnsiballZ_ibm_spectrumscale_node.py\", line 102, in <module>
    _ansiballz_main()
  File \"/root/.ansible/tmp/ansible-tmp-1605877443.8632338-520263-221689487663112/AnsiballZ_ibm_spectrumscale_node.py\", line 94, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File \"/root/.ansible/tmp/ansible-tmp-1605877443.8632338-520263-221689487663112/AnsiballZ_ibm_spectrumscale_node.py\", line 40, in invoke_module
    runpy.run_module(mod_name='ansible.modules.ibm_spectrumscale_node', init_globals=None, run_name='__main__', alter_sys=True)
  File \"/usr/lib64/python2.7/runpy.py\", line 176, in run_module
    fname, loader, pkg_name)
  File \"/usr/lib64/python2.7/runpy.py\", line 82, in _run_module_code
    mod_name, mod_fname, mod_loader, pkg_name)
  File \"/usr/lib64/python2.7/runpy.py\", line 72, in _run_code
    exec code in run_globals
  File \"/tmp/ansible_ibm_spectrumscale_node_payload_I5Yxxx/ansible_ibm_spectrumscale_node_payload.zip/ansible/modules/ibm_spectrumscale_node.py\", line 119, in <module>
ImportError: No module named ibm_spectrumscale_utils

This comes up in the task "delete | Delete an IBM Spectrum Scale Node from Cluster" in file core/cluster/tasks/removenode.yml, which uses a custom module. In understand that this is related to python2, which Ansible defaults to on RHEL 7 managed nodes.

As soon as I remove definition of state Ansible no longer runs the delete | Delete an IBM Spectrum Scale Node from Cluster task in core/cluster/tasks/removenode.yml and hence doesn't hit the error.

To Reproduce

  1. export ANSIBLE_ROLES_PATH=/path/to/ibm-spectrum-scale-install-infra/roles
  2. cat hosts:
    some-host  ansible_host=192.168.0.1  state=absent
  3. cat playbook.yml:
    ---
    - hosts: all
      vars_files:
        - vars.yml
      roles:
        - custom_module
        - core/precheck
        - core/node
        - core/cluster
        - core/postcheck
  4. ansible-playbook -i hosts playbook.yml

Environment

$ ansible --version
ansible 2.9.14
  config file = /home/achim/.ansible.cfg
  configured module search path = ['/home/achim/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.8/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.8.6 (default, Sep 25 2020, 00:00:00) [GCC 10.2.1 20200723 (Red Hat 10.2.1-1)]

$ python --version
Python 3.8.6

Ansible control node: Fedora release 32 (Thirty Two)

Managed node: Red Hat Enterprise Linux Server release 7.8 (Maipo)

I've further tested to define ansible_python_interpreter: /usr/bin/python3 to force Ansible to using python3 on the managed node. This, however, makes the playbook fail during precheck already:

TASK [core/precheck : prepare | List installed firewall RPMs] *******************************************************************************************************************************************************
fatal: [some-host]: FAILED! => {"changed": false, "msg": "The Python 2 bindings for rpm are needed for this module. If you require Python 3 support use the `dnf` Ansible module instead.. The Python 2 yum module is needed for this module. If you require Python 3 support use the `dnf` Ansible module instead."}

I see two options to fix this:

  1. Either make the custom modules work with python2 (default on RHEL 7)
  2. Or, fix the playbooks to work with python3 on RHEL 7. We would need to switch to the dnf module instead, not sure if this works and/or if there are furhter errors...

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions