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