sonic-net / sonic-mgmt

Configuration management examples for SONiC
Other
194 stars 712 forks source link

Encountered ModuleNotFoundError: No module named 'natsort' when setting up KVM testbed #3728

Open hsluoyz opened 3 years ago

hsluoyz commented 3 years ago

I'm following this docs: https://github.com/Azure/sonic-mgmt/blob/master/docs/testbed/README.testbed.VsSetup.md#vsonic to setup a testbed. I had an error running:

image

Error:

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ModuleNotFoundError: No module named 'natsort' fatal: [STR-ACS-VSERV-01 -> localhost]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n File \"/home/luo/.ansible/tmp/ansible-tmp-1625367004.6761444-45386379060534/AnsiballZ_conn_graph_facts.py\", line 102, in <module>\n _ansiballz_main()\n File \"/home/luo/.ansible/tmp/ansible-tmp-1625367004.6761444-45386379060534/AnsiballZ_conn_graph_facts.py\", line 94, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File \"/home/luo/.ansible/tmp/ansible-tmp-1625367004.6761444-45386379060534/AnsiballZ_conn_graph_facts.py\", line 40, in invoke_module\n runpy.run_module(mod_name='ansible.modules.conn_graph_facts', init_globals=None, run_name='__main__', alter_sys=True)\n File \"/usr/lib/python3.8/runpy.py\", line 207, in run_module\n return _run_module_code(code, init_globals, run_name, mod_spec)\n File \"/usr/lib/python3.8/runpy.py\", line 97, in _run_module_code\n _run_code(code, mod_globals, init_globals,\n File \"/usr/lib/python3.8/runpy.py\", line 87, in _run_code\n exec(code, run_globals)\n File \"/tmp/ansible_conn_graph_facts_payload_9ea4wxxs/ansible_conn_graph_facts_payload.zip/ansible/modules/conn_graph_facts.py\", line 11, in <module>\nModuleNotFoundError: No module named 'natsort'\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

It seems that natsort python module needs to be installed, but it's not mentioned in docs: https://github.com/Azure/sonic-mgmt/blob/master/docs/ansible/README.md#installing-ansible-on-ubuntu-14044-lts

image

Can we improve the docs for it?

Also the Ubuntu 14.04 mentioned in the docs is too old. I'm using Ubuntu 20.04 now. I don't know if there's any difference in the instructions..

Full log:


luo@ubuntu:~/Desktop/github_repos/sonic-mgmt/ansible$ ./testbed-cli.sh -t vtestbed.csv -m veos_vtb -k vsonic add-topo vms-kvm-t0 password.txt
Deploying topology 'vms-kvm-t0'
reading
Found topology vms-kvm-t0
[vlab-01] vlab-01
[WARNING]: Skipping plugin (/home/luo/Desktop/github_repos/sonic-mgmt/ansible/plugins/callback/yaml.py) as it seems to be invalid: type object 'SafeRepresenter' has
no attribute 'represent_unicode'

PLAY [servers:&vm_host] ***********************************************************************************************************************************************

TASK [Check for a single host] ****************************************************************************************************************************************
Sunday 04 July 2021  10:50:04 +0800 (0:00:00.085)       0:00:00.085 *********** 
[WARNING]: conditional statements should not include jinja2 templating delimiters such as {{ }} or {% %}. Found: {{ play_hosts|length }} != 1
skipping: [STR-ACS-VSERV-01]

TASK [Check that variable vm_set_name is defined] *********************************************************************************************************************
Sunday 04 July 2021  10:50:04 +0800 (0:00:00.115)       0:00:00.200 *********** 
skipping: [STR-ACS-VSERV-01]

TASK [Check that variable duts_name is defined] ***********************************************************************************************************************
Sunday 04 July 2021  10:50:04 +0800 (0:00:00.038)       0:00:00.238 *********** 
skipping: [STR-ACS-VSERV-01]

TASK [Check that variable VM_base is defined] *************************************************************************************************************************
Sunday 04 July 2021  10:50:04 +0800 (0:00:00.039)       0:00:00.278 *********** 
skipping: [STR-ACS-VSERV-01]

TASK [Check that variable ptf_ip is defined] **************************************************************************************************************************
Sunday 04 July 2021  10:50:04 +0800 (0:00:00.040)       0:00:00.318 *********** 
skipping: [STR-ACS-VSERV-01]

TASK [Check that variable ptf_ipv6 is defined] ************************************************************************************************************************
Sunday 04 July 2021  10:50:04 +0800 (0:00:00.034)       0:00:00.352 *********** 
skipping: [STR-ACS-VSERV-01]

TASK [Check that variable topo is defined] ****************************************************************************************************************************
Sunday 04 July 2021  10:50:04 +0800 (0:00:00.034)       0:00:00.387 *********** 
skipping: [STR-ACS-VSERV-01]

TASK [set_fact] *******************************************************************************************************************************************************
Sunday 04 July 2021  10:50:04 +0800 (0:00:00.034)       0:00:00.421 *********** 
ok: [STR-ACS-VSERV-01]

TASK [Check that topo is a known topology] ****************************************************************************************************************************
Sunday 04 July 2021  10:50:04 +0800 (0:00:00.042)       0:00:00.464 *********** 
skipping: [STR-ACS-VSERV-01]

TASK [Check that variable ptf_imagename is defined] *******************************************************************************************************************
Sunday 04 July 2021  10:50:04 +0800 (0:00:00.035)       0:00:00.499 *********** 
skipping: [STR-ACS-VSERV-01]

TASK [Load topo variables] ********************************************************************************************************************************************
Sunday 04 July 2021  10:50:04 +0800 (0:00:00.044)       0:00:00.544 *********** 
ok: [STR-ACS-VSERV-01]

TASK [Read duts minigraph] ********************************************************************************************************************************************
Sunday 04 July 2021  10:50:04 +0800 (0:00:00.041)       0:00:00.585 *********** 
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ModuleNotFoundError: No module named 'natsort'
fatal: [STR-ACS-VSERV-01 -> localhost]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n  File \"/home/luo/.ansible/tmp/ansible-tmp-1625367004.6761444-45386379060534/AnsiballZ_conn_graph_facts.py\", line 102, in <module>\n    _ansiballz_main()\n  File \"/home/luo/.ansible/tmp/ansible-tmp-1625367004.6761444-45386379060534/AnsiballZ_conn_graph_facts.py\", line 94, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/home/luo/.ansible/tmp/ansible-tmp-1625367004.6761444-45386379060534/AnsiballZ_conn_graph_facts.py\", line 40, in invoke_module\n    runpy.run_module(mod_name='ansible.modules.conn_graph_facts', init_globals=None, run_name='__main__', alter_sys=True)\n  File \"/usr/lib/python3.8/runpy.py\", line 207, in run_module\n    return _run_module_code(code, init_globals, run_name, mod_spec)\n  File \"/usr/lib/python3.8/runpy.py\", line 97, in _run_module_code\n    _run_code(code, mod_globals, init_globals,\n  File \"/usr/lib/python3.8/runpy.py\", line 87, in _run_code\n    exec(code, run_globals)\n  File \"/tmp/ansible_conn_graph_facts_payload_9ea4wxxs/ansible_conn_graph_facts_payload.zip/ansible/modules/conn_graph_facts.py\", line 11, in <module>\nModuleNotFoundError: No module named 'natsort'\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

PLAY RECAP ************************************************************************************************************************************************************
STR-ACS-VSERV-01           : ok=2    changed=0    unreachable=0    failed=1    skipped=9    rescued=0    ignored=0   

Sunday 04 July 2021  10:50:05 +0800 (0:00:00.466)       0:00:01.052 *********** 
=============================================================================== 
Read duts minigraph -------------------------------------------------------------------------------------------------------------------------------------------- 0.47s
Check for a single host ---------------------------------------------------------------------------------------------------------------------------------------- 0.12s
Check that variable ptf_imagename is defined ------------------------------------------------------------------------------------------------------------------- 0.04s
set_fact ------------------------------------------------------------------------------------------------------------------------------------------------------- 0.04s
Load topo variables -------------------------------------------------------------------------------------------------------------------------------------------- 0.04s
Check that variable VM_base is defined ------------------------------------------------------------------------------------------------------------------------- 0.04s
Check that variable duts_name is defined ----------------------------------------------------------------------------------------------------------------------- 0.04s
Check that variable vm_set_name is defined --------------------------------------------------------------------------------------------------------------------- 0.04s
Check that topo is a known topology ---------------------------------------------------------------------------------------------------------------------------- 0.04s
Check that variable ptf_ipv6 is defined ------------------------------------------------------------------------------------------------------------------------ 0.03s
Check that variable topo is defined ---------------------------------------------------------------------------------------------------------------------------- 0.03s
Check that variable ptf_ip is defined -------------------------------------------------------------------------------------------------------------------------- 0.03s
luo@ubuntu:~/Desktop/github_repos/sonic-mgmt/ansible$
···
wangxin commented 3 years ago

Did you run the testbed-cli.sh script inside a sonic-mgmt docker container?

image

If you use the sonic-mgmt docker container to run the testbed-cli.sh tool, there is no need to install dependencies stated in document https://github.com/Azure/sonic-mgmt/blob/master/docs/ansible/README.md#installing-ansible-on-ubuntu-14044-lts which is outdated. The default python environment in the sonic-mgmt docker container is python2. This should be able to temporarily workaround issue #3730