02-11-2021 02:50 PM
What I'm trying to do is to practice using Ansible against different devices in my CML Enterprise Snadbox (DevNet Sandbox - Workspace - Lab Catalog - Cisco Modeling Labs Enterprise). I personally am on a Windows 10 laptop with Windows Subsystem for Linux installed where I am able to run Ansible commands as well as ssh into my sandbox devices. To get started, all I'm trying to do is run a simple ping (ansible -m ping) against my 7 devices which are the DevBox, 2 nx-os switches, 2 IOS-XE routers, and 2 linux hosts. I am able to connect to the AnyConnect VPN as required to work with the sandbox labs, and I am able to SSH into all 7 devices from my machine using the sandbox provided credentials. I am also able to successfully ping the devbox through ansible as shown in this picture:
but I am getting errors when trying to ping the other devices in the exact same way as I do the devbox. Here are the ouputs I get when running the exact same command:
My ansible inventory file is very simple with 4 groups for each of the different types of devices (devbox, linuxhosts, switches, and routers - which is how I reference them in the ansible commands in the pictures above) and then a 'vars' group for each of those 4 groups where I define the ansible_ssh_user and ansible_ssh_pass variables with the provided credentials for each device from the sandbox. I have confirmed that all of the IP's for the devices and credentials are 100% correct.
My ansible.cfg file is also very simple with just these lines:
Solved! Go to Solution.
02-11-2021 06:40 PM
Max,
In your inventory file, in the vars section for the routers and switches, try adding:
ansible_connection=network_cli
I'm not sure from the specific error messages, but the sftp and scp mentions on the router error messages makes me wonder if you don't have that setting/variable. It tells the module to not ship aka transfer Python code to the network device for execution, but rather to execute it locally. You might also try this doc for more detail: https://docs.ansible.com/ansible/latest/network/getting_started/network_differences.html#
Let us know how it goes.
02-11-2021 06:40 PM
Max,
In your inventory file, in the vars section for the routers and switches, try adding:
ansible_connection=network_cli
I'm not sure from the specific error messages, but the sftp and scp mentions on the router error messages makes me wonder if you don't have that setting/variable. It tells the module to not ship aka transfer Python code to the network device for execution, but rather to execute it locally. You might also try this doc for more detail: https://docs.ansible.com/ansible/latest/network/getting_started/network_differences.html#
Let us know how it goes.
02-12-2021 08:47 AM - edited 02-12-2021 08:55 AM
Thank you! Added that line to the different groups and it now allows me to ping the 2 switches and routers, I'm still getting an error trying to run commands on the 2 linux hosts, but I assume I just need a different value for that ansible_connection variable or I need to set some other variable, which I am looking into now. Although my main focus was trying to get the switches and routers to work, so I appreciate the help!!!
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