Could not find imported module support code for version

Hi Team,

I preparing my test laboratory for a students for incoming sessions and first time I have faced a issue that I really dont know from where it came from…

Anyway…

We will trying prepare a host for a Oracle database installation and one of the step is to create filesystems before:

- name: Create a LV ora_inv for orainventory
  community.general.lvol:
    vg: orabinvg
    lv: ora_inv
    size: 500m
- name: Create filesystem for orainventory ora_inv
  community.general.filesystem:
    fstype: xfs
    dev: /dev/orabinvg/ora_inv

Playbook is failing with a error:

TASK [Create filesystem for orainventory ora_inv] ******************************************************************************************************************************************************
fatal: [ansibletargettst]: FAILED! => {“msg”: “Could not find imported module support code for version. Looked for either LooseVersion.py or version.py”}

Im confused as other modules from community.general are working fine. I dont see any information in documentation how to check that issue root cause…

Im using a old version of Centos 7.9 with python 2.7.5 and ansible 2.9.27 (I know that its a quite old envirnoment)

I have tried to play with python version as well but with no effects…

Is anyone saw it?

Those versions are on target machine or Ansible control node (the one you run Ansible on)?

This is most likely due to some Python version difference.

Well, it was one of the possibilities that I have checked and basically I have played with different python versions as well but with no luck.

On controler:

[root@ansiblecontroler ansible]# python --version
Python 2.7.5
[root@ansiblecontroler ansible]# ansible --version
ansible 2.9.27
config file = /etc/ansible/ansible.cfg
configured module search path = [u’/root/.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.5 (default, Nov 14 2023, 16:14:06) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)]

On target:

[root@ansibletargettst ~]# python --version
Python 2.7.5

I have also try to interpreter_python variable in ansible.cfg but with same effect…

On target I can see these:

(0, ‘ansible-tmp-1736835310.7-23357-113287981689819=/root/.ansible/tmp/ansible-tmp-1736835310.7-23357-113287981689819\n’, ‘’)
Using module file /usr/lib/python2.7/site-packages/ansible/modules/system/setup.py

Booth are a Vm machines cloned from same template in VirtualBox. Just ansible installed, python is exactly the same.

And can you find version.py there on either of the machines?

Since you are using old versions, it could just be a case of missing dependency that was not specified somewhere so it was not installed.

Are you maybe using community.general collection from the Galaxy or GitHub instead of using the one included in ansible package?

I have found that on target:

[root@ansibletargettst ~]# find /usr/lib/python2.7/ -name “version.py”
/usr/lib/python2.7/site-packages/tuned/version.py

‘community.general’ been installed by :

ansible-galaxy collection install community.general

As is in documentation.

When I trying to do it again:

[root@ansiblecontroler ansible]# ansible-galaxy collection install community.general
Process install dependency map
Starting collection install process
Skipping ‘community.general’ as it is already installed
[root@ansiblecontroler ansible]#

OK. version.py you have found is from the tuned package and is completely unrelated.

Which version of community.general are you currently using. You have to pay attention to compatibility. For example, latest version cannot be used with Ansible 2.9.x. You have to use very old version of the collection, somewhere around version 4.x.x. Ansible version requirements for each collection can be seen on Galaxy page:

https://galaxy.ansible.com/ui/repo/published/community/general

P.S. If you are following any documentation, you have to follow documentation for Ansible 2.9.x. Ansible 2.10.x was a breaking point in Ansible development.

https://docs.ansible.com/ansible/2.9/

community.general dropped support for Ansible 2.9 in version 5.0.0 (see the 5.0.0 changelog entry), every version before that should work.

In any case, both CentOS 7, Ansible 2.9, and community.general 4.x.y are End of Life and should be avoided if possible. Also note that Ansible 2.9 didn’t warn when a collection is marked as incompatible with this Ansible version. Later versions do that.

1 Like

Thank you for a help.

I have created a new setup with Centos 8.5, python 3.6.8 and ansible 2.11.12 and now its working good. Im a bit surprised that older configuration is not automatically adujsted for older version but understand that centos 7 is already not supported.

Thanks!