cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
195
Views
5
Helpful
2
Replies
Max_K
Beginner

Need help running Ansible against my CML Sandbox Devices

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:

devbox.PNG

 

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:

linuxhosts.PNGrouters.PNGswitcherror.PNG

 

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:

[defaults]
inventory = ./inventory/myhosts
host_key_checking = False

[ssh connection]
ssh_args = -o ControlMaster=no

I know my inventory file path is correct. I am not entirely sure what the host_key_checking or ssh_args lines each do, but I was told that they are necessary (ssh_args line I heard was necessary because I am using windows subsystem for linux). I have a feeling that I am missing something in this file that will allow me to run ansible commands on all of the devices, but I have no idea what it could be, or it may be a different issue.

As I said before, I can ssh to all 7 devices from my home laptop without any issues. But when I try to run ansible commands on them (ansible uses ssh to connect to all the devices), it does not work for 6 out of the 7. If anyone is able to help me in any way I would greatly appreciate it! If you need any more information from me in order to better understand my issue, please let me know. Thank you!

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
WendellO
Contributor

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.

View solution in original post

2 REPLIES 2
WendellO
Contributor

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.

View solution in original post

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!!!

Content for Community-Ad