cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1088
Views
0
Helpful
2
Replies

Can't ping cisco IOS using ansible

teamdv6199
Level 1
Level 1

I am trying to do a ping from my ansible linux box to a cisco switch. When I run ansible-playbook test.yml -kK I get the following:

BECOME password[defaults to SSH password]:
[WARNING]: * Failed to parse /home/username/cisco-demo/inventory with yaml plugin: We
were unable to read either as JSON nor YAML, these are the errors we got from each: JSON:
Expecting value: line 2 column 2 (char 2) Syntax Error while loading YAML. did not find
expected <document start> The error appears to be in '/home/username/cisco-
demo/inventory': line 3, column 1, but may be elsewhere in the file depending on the exact
syntax problem. The offending line appears to be: [routers] router-1
ansible_host=192.x.x.x ^ here
[WARNING]: * Failed to parse /home/username/cisco-demo/inventory with ini plugin:
/home/username/cisco-demo/inventory:14: Expected key=value host variable assignment, got:
paramiko
[WARNING]: Unable to parse /home/username/cisco-demo/inventory as an inventory source
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the
implicit localhost does not match 'all'

PLAY [routers] *****************************************************************************

TASK [do a basic ping] *********************************************************************
fatal: [router-1]: FAILED! => {"changed": false, "msg": "paramiko is not installed: No module named 'paramiko'"}

 

I am on a redhat machine with no internet access.

 

Below is my inventory file and ansible.cfg

[routers]
router-1 ansible_host=192.x.x.x

[routers:vars]
ansible_network_os=ios
ansible_user=username
ansible_connection=network_cli


[persistent_connection]

ssh_type = paramiko



Ansible.cfg:

[defaults]
inventory = ./inventory
COLLECTIONS_PATHS = ./collections
remote_user = venom
#host_key_checking=False
#[ssh_connection]
#scp_if_ssh=True
[persistent_connection]
ssh_type = paramiko

[privilege_escalation]
#ansible_connection: ansible.netcommon.network_cli
#ansible_network_os: cisco.ios.ios
ansible_become: true
ansible_become_method: enable
#ansible_port=8181
become_user = username

parmiko looks like its installed:

python3 -m pip install paramiko --user


Looking in indexes: https://myrepohere/PIP/simple/
Requirement already satisfied: paramiko in ./.local/lib/python3.10/site-packages (2.1.6)
Requirement already satisfied: cryptography>=1.1 in /opt/anaconda3/lib/python3.10/site-packages (from paramiko) (39.0.1)
Requirement already satisfied: pyasn1>=0.1.7 in /opt/anaconda3/lib/python3.10/site-packages (from paramiko) (0.4.8)
Requirement already satisfied: cffi>=1.12 in /opt/anaconda3/lib/python3.10/site-packages (from cryptography>=1.1->paramiko) (1.15.1)
Requirement already satisfied: pycparser in /opt/anaconda3/lib/python3.10/site-packages (from cffi>=1.12->cryptography>=1.1->paramiko) (2.21)
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv

 

 

 

 

 

2 Replies 2

Check that the network_cli connection plugin is installed on your Ansible controller. You can do this by running the following command:

ansible -m setup | grep network_cli
Please mark this as helpful or solution accepted to help others
Connect with me https://bigevilbeard.github.io

I think it is I am sing ansible galaxy to install it. znsible.netcommon is what I researched is what i need.

 

ansible-galaxy collection list

# /home/cisco-demo/collections/ansible_collections
Collection Version
----------------- -------
ansible.netcommon 5.2.0
ansible.utils 2.11.0
cisco.ios 5.0.0