We are in the process of bringing up KVM testbed setup to run the test suites and
When we tried to deploy the VM using below command we are facing an error libvirt module is not importable . Our testing environmental set up described below, Could you suggest a solution to bring up a KVM testbed setup.
1. Ubuntu 18.04 installed on a physical machine
Intel processor
Virtualization enabled in bios level
32 GB RAM
2. Python3 installed
sudo apt install python python-pip openssh-server
sudo pip install j2cli==0.3.10
3. Run the host setup script to install required packages and initialize the management bridge network
git clone
https://github.com/sonic-net/sonic-mgmt cd sonic-mgmt/ansible
sudo ./setup-management-network.sh
4. Docker(sonic-mgmt) installed. ubuntu 20.04 on the Inside the docker
5. vEOS (kvm based)image copied to ~/veos-vm/images
6. Run the setup-container.sh in the root directory of the sonic-mgmt repository
cd sonic-mgmt
./setup-container.sh -n sonic-mgmt -d /data
start the docker --> docker start sonic-mgmt
enter to the docker --> docker exec -it <container name> bash
sonic-mgmt directory mounted at /data/sonic-mgmt
7. Modified /data/sonic-mgmt/ansible/veos_vtb to use the user name
STR-ACS-VSERV-01:
ansible_host: 172.17.0.1
ansible_user: sonic
vm_host_user: foo
8. Modified /data/sonic-mgmt/ansible/ansible.cfg to uncomment the two lines
become_user='root'
become_ask_pass=False
9. Modified /data/sonic-mgmt/ansible/group_vars/vm_host/creds.yml
ansible_user: sonic
ansible_password: admin123
ansible_become_password: admin123
# Use the following username/password variables to login to vm hosts
# instead of the default variables (defined above).
vm_host_user: foo
vm_host_password: foo123
vm_host_become_password: foo123
10. Created a dummy password.txt file under /data/sonic-mgmt/ansible
11. On the host, run sudo visudo and added the following line at the end
sonic ALL=(ALL) NOPASSWD:ALL
foo ALL=(ALL) NOPASSWD:ALL
12.sonic@bf124e552bad:/data/sonic-mgmt/ansible$ ./testbed-cli.sh -m veos_vtb -n 4 -k vsonic start-vms server_1 password.txt
Error Log:
sonic@bf124e552bad:/data/sonic-mgmt/ansible$ ./testbed-cli.sh -m veos_vtb -n 4 -k vsonic start-vms server_1 password.txt
Starting VMs on server 'server_1'
[WARNING] Ansible is being run in a world writable directory (/data/sonic-mgmt/ansible), ignoring it as an ansible.cfg source. For more information see http
s://
docs.ansible.com/ansible/devel/reference_appendices/config.html#cfg-in-world-writable-dir/usr/local/lib/python2.7/dist-packages/ansible/parsing/vault/__init__.py:44: CryptographyDeprecationWarning: Python 2 is no longer supported by the Python co
re team. Support for it is now deprecated in cryptography, and will be removed in the next release.
from cryptography.exceptions import InvalidSignature
PLAY [servers:&vm_host] *************************************************************************************************************************************
TASK [vm_set : Set the default variable package_installation] ***********************************************************************************************
ok: [STR-ACS-VSERV-01]
TASK [vm_set : get host distribution] ***********************************************************************************************************************
[DEPRECATION WARNING]: Distribution Ubuntu 18.04 on host STR-ACS-VSERV-01 should use /usr/bin/python3, but is using /usr/bin/python for backward
compatibility with prior Ansible releases. A future Ansible release will default to using the discovered platform python for this host. See
https://docs.ansible.com/ansible/2.8/reference_appendices/interpreter_discovery.html for more information. This feature will be removed in version 2.12.
Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
ok: [STR-ACS-VSERV-01]
TASK [vm_set : get host distribution version] ***************************************************************************************************************
ok: [STR-ACS-VSERV-01]
TASK [vm_set : get host kernel version] *********************************************************************************************************************
ok: [STR-ACS-VSERV-01]
TASK [vm_set : Check if kernel upgrade needed] **************************************************************************************************************
skipping: [STR-ACS-VSERV-01]
TASK [vm_set : debug] ***************************************************************************************************************************************
skipping: [STR-ACS-VSERV-01]
TASK [vm_set : Upgrade kernel package] **********************************************************************************************************************
[DEPRECATION WARNING]: Invoking "apt" only once while using a loop via squash_actions is deprecated. Instead of using a loop to supply multiple items and
specifying `pkg: "{{ item }}"`, please use `pkg: ['linux-image-generic', 'linux-image-extra-virtual']` and remove the loop. This feature will be removed in
version 2.11. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
skipping: [STR-ACS-VSERV-01] => (item=[])
TASK [vm_set : Prompt for rebooting] ************************************************************************************************************************
skipping: [STR-ACS-VSERV-01]
TASK [vm_set : Install necessary packages] ******************************************************************************************************************
[DEPRECATION WARNING]: Invoking "apt" only once while using a loop via squash_actions is deprecated. Instead of using a loop to supply multiple items and
specifying `pkg: "{{ item }}"`, please use `pkg: ['ifupdown', 'qemu', 'openvswitch-switch', 'net-tools', 'bridge-utils', 'util-linux', 'iproute2', 'vlan',
'apt-transport-https', 'ca-certificates', 'curl', 'software-properties-common', 'libvirt-clients']` and remove the loop. This feature will be removed in
version 2.11. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
ok: [STR-ACS-VSERV-01] => (item=[u'ifupdown', u'qemu', u'openvswitch-switch', u'net-tools', u'bridge-utils', u'util-linux', u'iproute2', u'vlan', u'apt-transport-https', u'ca-certificates', u'curl', u'software-properties-common', u'libvirt-clients'])
TASK [vm_set : Install necessary packages] ******************************************************************************************************************
ok: [STR-ACS-VSERV-01]
TASK [vm_set : Install necessary packages] ******************************************************************************************************************
skipping: [STR-ACS-VSERV-01]
TASK [vm_set : Get default pip_executable] ******************************************************************************************************************
ok: [STR-ACS-VSERV-01]
TASK [vm_set : Get default pip_executable] ******************************************************************************************************************
skipping: [STR-ACS-VSERV-01]
TASK [vm_set : remove old python packages] ******************************************************************************************************************
ok: [STR-ACS-VSERV-01]
TASK [vm_set : include_tasks] *******************************************************************************************************************************
included: /data/sonic-mgmt/ansible/roles/vm_set/tasks/docker.yml for STR-ACS-VSERV-01
TASK [vm_set : Add docker official GPG key] *****************************************************************************************************************
ok: [STR-ACS-VSERV-01]
TASK [vm_set : Check docker repository] *********************************************************************************************************************
ok: [STR-ACS-VSERV-01]
TASK [vm_set : Report docker repository exists] *************************************************************************************************************
ok: [STR-ACS-VSERV-01] => {
"msg": "Docker repository already exists"
}
TASK [vm_set : Report docker repository not exists] *********************************************************************************************************
skipping: [STR-ACS-VSERV-01]
TASK [vm_set : Add docker repository for 16.04] *************************************************************************************************************
skipping: [STR-ACS-VSERV-01]
TASK [vm_set : Add docker repository for 17.04] *************************************************************************************************************
skipping: [STR-ACS-VSERV-01]
TASK [vm_set : Add docker repository for 18.04] *************************************************************************************************************
skipping: [STR-ACS-VSERV-01]
TASK [vm_set : Add docker repository for 20.04] *************************************************************************************************************
skipping: [STR-ACS-VSERV-01]
TASK [vm_set : Run the "apt-get update" as a separate and retryable step] ***********************************************************************************
changed: [STR-ACS-VSERV-01]
TASK [vm_set : Install docker-ce] ***************************************************************************************************************************
ok: [STR-ACS-VSERV-01]
TASK [vm_set : remove old python packages] ******************************************************************************************************************
ok: [STR-ACS-VSERV-01]
TASK [vm_set : Install python packages] *********************************************************************************************************************
changed: [STR-ACS-VSERV-01]
TASK [vm_set : Ensure sonic in docker,sudo group] ***********************************************************************************************************
ok: [STR-ACS-VSERV-01]
TASK [vm_set : Ensure sonic in libvirt group] ***************************************************************************************************************
skipping: [STR-ACS-VSERV-01]
TASK [vm_set : Install br_netfilter kernel module] **********************************************************************************************************
ok: [STR-ACS-VSERV-01]
TASK [vm_set : Set sysctl bridge parameters for testbed] ****************************************************************************************************
ok: [STR-ACS-VSERV-01] => (item=net.bridge.bridge-nf-call-arptables)
ok: [STR-ACS-VSERV-01] => (item=net.bridge.bridge-nf-call-ip6tables)
ok: [STR-ACS-VSERV-01] => (item=net.bridge.bridge-nf-call-iptables)
TASK [vm_set : Set sysctl RCVBUF max parameter for testbed] *************************************************************************************************
ok: [STR-ACS-VSERV-01]
TASK [vm_set : Set sysctl RCVBUF default parameter for testbed] *********************************************************************************************
ok: [STR-ACS-VSERV-01]
TASK [vm_set : Setup external front port] *******************************************************************************************************************
skipping: [STR-ACS-VSERV-01]
TASK [vm_set : Setup internal management network] ***********************************************************************************************************
skipping: [STR-ACS-VSERV-01]
TASK [vm_set : getent] **************************************************************************************************************************************
ok: [STR-ACS-VSERV-01]
TASK [vm_set : set_fact] ************************************************************************************************************************************
ok: [STR-ACS-VSERV-01]
TASK [vm_set : set_fact] ************************************************************************************************************************************
[WARNING]: conditional statements should not include jinja2 templating delimiters such as {{ }} or {% %}. Found: not '{{ root_path }}'.startswith('/')
ok: [STR-ACS-VSERV-01]
TASK [vm_set : debug] ***************************************************************************************************************************************
ok: [STR-ACS-VSERV-01] => {
"msg": "home_path = /home/sonic root_path = /home/sonic/veos-vm"
}
TASK [vm_set : Require veos or SONiC VMs by default] ********************************************************************************************************
ok: [STR-ACS-VSERV-01]
TASK [vm_set : veos or SONiC VMs not needed when setting up Kubernetes master] ******************************************************************************
skipping: [STR-ACS-VSERV-01]
TASK [vm_set : VMs not needed in case of Keysight API Server] ***********************************************************************************************
skipping: [STR-ACS-VSERV-01]
TASK [vm_set : VMs not needed in case of Keysight IxANVL] ***************************************************************************************************
skipping: [STR-ACS-VSERV-01]
TASK [vm_set : Retrieve a list of the defined VMs] **********************************************************************************************************
fatal: [STR-ACS-VSERV-01]: FAILED! => {"changed": false, "msg": "The `libvirt` module is not importable. Check the requirements."}
PLAY RECAP **************************************************************************************************************************************************
STR-ACS-VSERV-01 : ok=26 changed=2 unreachable=0 failed=1 skipped=17 rescued=0 ignored=0
sonic@bf124e552bad:/data/sonic-mgmt/ansible$