# Ansible with network equipment (Comware 5 switch)

**URL:** <https://forum.ansible.com/t/ansible-with-network-equipment-comware-5-switch/31005>\
**Category:** Ansible Project\
**Created:** [August 9, 2019, 1:41pm UTC](https://forum.ansible.com/t/ansible-with-network-equipment-comware-5-switch/31005 "2019-08-09T13:41:16Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ugo\_Bellavance](https://avatars.discourse-cdn.com/v4/letter/u/e480ec/32.png) [@Ugo\_Bellavance](https://forum.ansible.com/u/Ugo_Bellavance)\
**Post date:** [August 9, 2019, 1:41pm UTC](https://forum.ansible.com/t/ansible-with-network-equipment-comware-5-switch/31005/1 "2019-08-09T13:41:16Z")

</div>

Hi,

I’m new to Ansible. I wanted to manage my network devices with Ansible so I did this:

- Found this documentation: [http://patg.net/ansible,comware,switches/2014/10/16/ansible-comware/](http://patg.net/ansible,comware,switches/2014/10/16/ansible-comware/)

- Created an account on my switch, tested that it can login via SSH (password only, haven’t configured an SSH key yet)

- Installed ansible (from EPEL), on RHEL7 (see below for version details)

- Cloned the comware 5.2 module in $HOME/.ansible/plugins/modules (git clone [https://github.com/CaptTofu/comware\_5\_2.git](https://github.com/CaptTofu/comware_5_2.git))

- Cloned the Github project to get playbook examples (git clone [https://github.com/CaptTofu/comware\_5\_2\_playbooks.git](https://github.com/CaptTofu/comware_5_2_playbooks.git))

- Created an inventory file (see below)

- Created a playbook (see below)

- Ran ansible-playbook (ansible-playbook -i switch1 -u ansiblehpe --ask-pass playbook1.yml)

- Got this error message

- fatal: [192.168.xx.xx]: FAILED! =\> {“msg”: “module (setup) is missing interpreter line”}- So I though I would add the shebang with the path of the python interpeter on my server running ansible in the setup.py file

- Got these errors:

- [WARNING]: Unhandled error in Python interpreter discovery for host 192.168.99.41: Failed to connect to the host via ssh:

- [WARNING]: sftp transfer mechanism failed on [192.168.99.41]. Use ANSIBLE\_DEBUG=1 to see detailed information

- [WARNING]: scp transfer mechanism failed on [192.168.99.41]. Use ANSIBLE\_DEBUG=1 to see detailed information- I realized ansible wanted to discover where could python be on the remote target, but there isn’t any interpreter there, it’s a network switch…

- I set an empty shebang in the setup.py file and got this error

- An exception occurred during task execution. To see the full traceback, use -vvv. The error was: IndexError: list index out of range  
fatal: [192.168.99.41]: FAILED! =\> {“msg”: “Unexpected failure during module execution.”, “stdout”: “”}

How do I tell ansible that there isn’t any interpreter on the target?

Any help would be appreciated.  
Thanks in advance.

$ ansible --version  
ansible 2.8.2  
config file = /etc/ansible/ansible.cfg  
configured module search path = [u’/home/ubellavance/.ansible/plugins/modules’, u’/usr/share/ansible/plugins/modules’]  
ansible python module location = /usr/lib/python2.7/site-packages/ansible  
executable location = /usr/bin/ansible  
python version = 2.7.5 (default, Jun 11 2019, 12:19:05) [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)]

Inventory file:

[switch1]  
192.168.xx.xx

[switch1:vars]  
switch\_host=192.168.xx.xx  
switch\_user=xxxxxxxx  
switch\_password=xxxxxxxx

Playbook:

- hosts: switch1  
tasks:
- name: gather facts from switch  
comware\_5\_2:  
gather\_facts=true  
host={{ switch\_host }}  
username={{ switch\_user }}  
password={{ switch\_password }}

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [August 10, 2019, 4:17pm UTC](https://forum.ansible.com/t/ansible-with-network-equipment-comware-5-switch/31005/2 "2019-08-10T16:17:46Z")

</div>

Default the first thing Ansible does is to gather facts, this is the setup module.  
Since you switch don't have Python this will not work an need to be disables by setting gather\_facts: no on the play.

---

<div class="post-metadata">

**Author:** ![Ugo\_Bellavance](https://avatars.discourse-cdn.com/v4/letter/u/e480ec/32.png) [@Ugo\_Bellavance](https://forum.ansible.com/u/Ugo_Bellavance)\
**Post date:** [August 11, 2019, 11:44pm UTC](https://forum.ansible.com/t/ansible-with-network-equipment-comware-5-switch/31005/3 "2019-08-11T23:44:08Z")

</div>

According to the blog post, it is supposed to work, but Ansible is supposed to use switch commands to get facts, not python. Is there a way to tell Ansible not to try to discover python on the remote target?

Thanks,

---

<div class="post-metadata">

**Author:** ![Jonathan\_Lozada\_De\_L](https://avatars.discourse-cdn.com/v4/letter/j/eb8c5e/32.png) [@Jonathan\_Lozada\_De\_L](https://forum.ansible.com/u/Jonathan_Lozada_De_L)\
**Post date:** [August 12, 2019, 5:54am UTC](https://forum.ansible.com/t/ansible-with-network-equipment-comware-5-switch/31005/4 "2019-08-12T05:54:07Z")

</div>

can you provie the playbook file

Jonathan Lozada De La Matta on mobile

– You received this message because you are subscribed to the Google Groups “Ansible Project” group. To unsubscribe from this group and stop receiving emails from it, send an email to . To view this discussion on the web visit .

---

<div class="post-metadata">

**Author:** ![ganeshrn](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/ganeshrn/32/1021_2.png) [@ganeshrn](https://forum.ansible.com/u/ganeshrn)\
**Post date:** [August 12, 2019, 7:30am UTC](https://forum.ansible.com/t/ansible-with-network-equipment-comware-5-switch/31005/5 "2019-08-12T07:30:46Z")

</div>

The module seems to use [paramiko\_ssh](https://github.com/CaptTofu/comware_5_2/blob/master/comware_5_2.py#L93) to connect to the remote host.  
Try changing the inventory entry as below since the module is expected to run on the control node.

[switch1]  
192.168.xx.xx ansible\_connection=local

OR

[switch1]  
localhost

Also, this seems to be a very old module and not using the Ansible persistent connection framework.  
You can add Ansible cliconf and terminal plugins for the network os to make it work with [connection=network\_cli](https://github.com/ansible/community/blob/master/group-network/network_dev_network_cli.rst)  
After adding the required plugins you use [cli\_command](https://docs.ansible.com/ansible/latest/modules/cli_command_module.html)and [cli\_config](https://docs.ansible.com/ansible/latest/modules/cli_config_module.html) modules to manage the remote host.

---

<div class="post-metadata">

**Author:** ![Shane\_Carnahan](https://avatars.discourse-cdn.com/v4/letter/s/8edcca/32.png) [@Shane\_Carnahan](https://forum.ansible.com/u/Shane_Carnahan)\
**Post date:** [August 12, 2019, 12:35pm UTC](https://forum.ansible.com/t/ansible-with-network-equipment-comware-5-switch/31005/6 "2019-08-12T12:35:31Z")

</div>

Specify the connect fo the host as below:  
ansible\_connection: network\_cli

[https://docs.ansible.com/ansible/latest/plugins/connection/network\_cli.html](https://docs.ansible.com/ansible/latest/plugins/connection/network_cli.html)

---

<div class="post-metadata">

**Author:** ![Ugo\_Bellavance](https://avatars.discourse-cdn.com/v4/letter/u/e480ec/32.png) [@Ugo\_Bellavance](https://forum.ansible.com/u/Ugo_Bellavance)\
**Post date:** [August 13, 2019, 3:46am UTC](https://forum.ansible.com/t/ansible-with-network-equipment-comware-5-switch/31005/7 "2019-08-13T03:46:03Z")

</div>

The playbook is in my original post.
