Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The module ndmtk was not found in configured module paths #23

Open
MohanrajBabu opened this issue Feb 17, 2021 · 1 comment
Open

The module ndmtk was not found in configured module paths #23

MohanrajBabu opened this issue Feb 17, 2021 · 1 comment

Comments

@MohanrajBabu
Copy link

Hello,

Followed below steps in installing ndmtk.

[root@localhost collect_data]# pip install ndmtk
Collecting ndmtk
  Using cached https://files.pythonhosted.org/packages/5d/12/649225c25b943b495e4b4c890542699fd68cbdc678ae5abbc1d4d883e35f/ndmtk-0.2.0.tar.gz
Requirement already satisfied (use --upgrade to upgrade): ansible>=2.0 in /usr/lib/python2.7/site-packages (from ndmtk)
Requirement already satisfied (use --upgrade to upgrade): jinja2 in /usr/lib/python2.7/site-packages (from ansible>=2.0->ndmtk)
Requirement already satisfied (use --upgrade to upgrade): PyYAML in /usr/lib64/python2.7/site-packages (from ansible>=2.0->ndmtk)
Requirement already satisfied (use --upgrade to upgrade): cryptography in /usr/lib64/python2.7/site-packages (from ansible>=2.0->ndmtk)
Requirement already satisfied (use --upgrade to upgrade): markupsafe in /usr/lib64/python2.7/site-packages (from jinja2->ansible>=2.0->ndmtk)
Requirement already satisfied (use --upgrade to upgrade): idna>=2.0 in /usr/lib/python2.7/site-packages (from cryptography->ansible>=2.0->ndmtk)
Requirement already satisfied (use --upgrade to upgrade): pyasn1>=0.1.8 in /usr/lib/python2.7/site-packages (from cryptography->ansible>=2.0->ndmtk)
Requirement already satisfied (use --upgrade to upgrade): six>=1.4.1 in /usr/lib/python2.7/site-packages (from cryptography->ansible>=2.0->ndmtk)
Requirement already satisfied (use --upgrade to upgrade): setuptools in /usr/lib/python2.7/site-packages (from cryptography->ansible>=2.0->ndmtk)
Requirement already satisfied (use --upgrade to upgrade): enum34 in /usr/lib/python2.7/site-packages (from cryptography->ansible>=2.0->ndmtk)
Requirement already satisfied (use --upgrade to upgrade): ipaddress in /usr/lib/python2.7/site-packages (from cryptography->ansible>=2.0->ndmtk)
Requirement already satisfied (use --upgrade to upgrade): cffi>=1.4.1 in /usr/lib64/python2.7/site-packages (from cryptography->ansible>=2.0->ndmtk)
Requirement already satisfied (use --upgrade to upgrade): pycparser in /usr/lib/python2.7/site-packages (from cffi>=1.4.1->cryptography->ansible>=2.0->ndmtk)
Installing collected packages: ndmtk
  Running setup.py install for ndmtk ... done
Successfully installed ndmtk

When tried to run a sample playbook, getting below error.

[root@localhost collect_data]# ansible-playbook -i hosts site.yml

PLAY [Collect Common data] ***********************************************************************************************************************************************

TASK [collect_common : data collection from three network devices] *******************************************************************************************************
fatal: [192.168.43.89]: FAILED! => {"msg": "The module ndmtk was not found in configured module paths"}
fatal: [192.168.43.87]: FAILED! => {"msg": "The module ndmtk was not found in configured module paths"}

PLAY RECAP ***************************************************************************************************************************************************************
192.168.43.89              : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   
192.168.43.87              : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   

How to fix this issue?

Thanks,
Mohan

@greenpau
Copy link
Owner

How to fix this issue?

@MohanrajBabu , the reason for this is ndmtk gets injected into ansible's module path via a symlink at the installation time.

ndmtk/setup.py

Lines 117 to 135 in d4c9927

'''
Create a symlink, i.e. `ln -s TARGET LINK_NAME`
'''
_egg_files = [];
for ansible_dir in ansible_dirs:
for i in ['action', 'callback']:
symlink_target = os.path.join(plugin_dir, 'plugins/' + i + '/ndmtk.py');
symlink_name = os.path.join(ansible_dir, 'plugins/' + i + '/ndmtk.py');
try:
os.symlink(symlink_target, symlink_name);
os.chmod(symlink_name, stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH);
_egg_files.append(symlink_name);
_egg_files.append(symlink_name + 'c');
print("[INFO] created symlink '" + symlink_name + "' to plugin '" + symlink_target + "'");
except:
exc_type, exc_value, exc_traceback = sys.exc_info();
print('[ERROR] an attempt to create a symlink ' + symlink_name + ' to plugin ' + symlink_target + ' failed, aborting!');
print(traceback.format_exception(exc_type, exc_value, exc_traceback));
return;

It looks like it did not happen here. Reasons:

  1. something changed in ansible api
  2. some variation in you system why

This function looks for ansible packages:

ndmtk/setup.py

Lines 69 to 75 in d4c9927

ansible_dirs = _find_py_package('ansible');
if len(ansible_dirs) == 0:
print("[ERROR] 'ansible' python package was not found");
return [];
print("[INFO] the path to 'ansible' python package is: " + str(ansible_dirs));
remove_ansible_files(ansible_dirs);
return ansible_dirs;

It iterates over site-packages.

ndmtk/setup.py

Line 81 in d4c9927

def _find_py_package(name):

Do you have multiple ansible modules in your site-packages? If you have egg file, then ndmtk will not have a way to inject itself into ansible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants