Ansible with network equipment (Comware 5 switch)

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/

  • 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)

  • Cloned the Github project to get playbook examples (git clone 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 }}

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.

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,

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 .

The module seems to use paramiko_ssh 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
After adding the required plugins you use cli_command and cli_config modules to manage the remote host.

Specify the connect fo the host as below:
ansible_connection: network_cli

https://docs.ansible.com/ansible/latest/plugins/connection/network_cli.html

The playbook is in my original post.