10-11-2023 03:06 PM
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
10-12-2023 04:51 AM
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
10-16-2023 09:06 AM
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
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide