I’m going to guess that your which python is not /usr/bin/python
Ansible by default runs all modules using /usr/bin/python. If your default python is something like /usr/local/bin/python then chances are, that those 2 pythons do not share the same site-packages, and you may have installed that module using /usr/local/bin/python
You can try something like the following to verify:
I always do use virtualenv and always do use #!/usr/bin/env python
I think the situation is that I use the virtualenv.
How does one ensure that if they are running ansible in a virtualenv that any host it runs against has the same modules? It creates a temp dir on the host it runs on and that temp dir has everything that is needed, right? How does one make sure that temp dir has everything that is needed?
I solved the issue by installing the module systemically.
Are you saying that you solved the problem by installing the ComWare
module onto each machine that you are managing with ansible?
If so, ansible currently does not look at an ansible module's
dependencies and transfer those to the client. It looks at a few
special imports to determine if it needs to include code from within
ansible in the transfer but doesn't have a general facility to handle
other python modules (Look at ModuleReplacer https://github.com/ansible/ansible/blob/devel/lib/ansible/module_common.py#L36
if you want details).
In the playbook I use to provision new boxes I use the ansible package
manager modules to install python module packages I know will be
needed on the client. Other people might install these via the tools
the OS provides for installing itself or as a first step in a playbook
that uses the python modules. If a module is not available in your
package manager, you can use the copy or synchronize modules to copy
the module over instead.