I’m developing several new network modules for Ansible 2.3. I have placed the common functions that are shared among these modules in a python script and put it in ./module_utils/cnos/cnos.py. “cnos” is our operating system name, hence the name cnos.
The modules that use this library import it via “import cnos” , however when they run, I get the following error:
[WARNING]: Removed unexpected internal key in module return: _ansible_parsed = False
An exception occurred during task execution. The full traceback is:
Traceback (most recent call last):
File “/tmp/ansible_G7YHg_/ansible_module_cnos_command.py”, line 157, in
main()
File “/tmp/ansible_G7YHg_/ansible_module_cnos_command.py”, line 131, in main
output = output + cnos.waitForDeviceResponse(“\n”, “>”, 2, remote_conn)
NameError: global name ‘cnos’ is not defined
This is rectified by setting the PYTHONPATH to this value: /usr/local/lib/python2.7/dist-packages/ansible-2.3.0-py2.7.egg/ansible/module_utils
I am working from the development branch and after I ‘make’ it I install ansible via:
python setup.py install
Will the requirement to set PYTHONPATH be eliminated when official RCs are created, or is there something I’m doing wrong here…
Thanks