• Zach Biles

Useful Ansible Ad-Hoc Commands

Ansible doesn’t always have to be crazy complex playbooks doing super cool stuff. Sometimes, it’s really useful to get some output from al your devices like versioning, VLANs, IP addresses, etc... Here I plan to collect some of the one-liners I end up using so others can see what’s possible. This will be a dynamic post, so check back over time!


Find if a VLAN exists on your gear:

This command string will run a ”show vlan brief” command on your devices, and return the output. Then only include lines based on the grep filter. Basically, if the line in the output contains Changed, error, failed, or unreachable it will include this in the output. This way, you can see which device might not have been online or failed to return output. Then it will also include lines with the VLAN number you are looking for. In this case, 4092.

ansible all -i switch_hosts -m raw -a "show vlan brief" | grep 'CHANGED\|ERROR\|FAILED\|UNREACHABLE\|4092'

Check for a specific line in your configuration file:

This command will look run “show running-config” on your devices and return back if “service password encryption” is in your configuration. This is something you should always have enabled on Cisco devices.

ansible all -i switch_hosts -m raw -a "show running-config | include service" | grep 'CHANGED\|ERROR\|FAILED\|UNREACHABLE\|encryption'

Recent Posts

See All

Ansible/AWX Custom Credential Types

Sometimes in Ansible you need to support legacy devices, or API’s that require hard coded passwords or API strings in your playbooks. One way around this is to use custom credential objects in AWX/Tow

Cisco VLANs to MikroTik

Why VLANs? When I first started trying to setup my first MikroTik device, I very quickly ran into issues trying to configure VLANs. Using VLANs is so second-nature to me now coming from a Cisco backgr

LINKS
ABOUT

info@sisulink.com

Inside TechTank

3709 1st Ave

Hibbing, MN 55746, USA

SOCIAL
  • sisuLink on Facebook!

© 2020 sisuLink.