These examples were built using ansible version 2.9.2.
- To run
cisco-playbook.yaml
with theios_command
module and ask for passwords before connecting:
# iterate over hosts in inventory.ini and save 'show runn' as a file for each
ansible-playbook -i inventory.ini -k -K cisco-playbook.yaml
- To run
linux-playbook.yaml
and ask for passwords before connecting:- This
linux-playbook
runs a command using thecommand
module - This
linux-playbook
runs another command using theshell
module
- This
# This goes through localhost and saves 'sudo ls -la' as a file
ansible-playbook -i inventory.ini -k -K linux-playbook.yaml
- To run a
ping
from a switch with theraw
module-k -K
asks for passwords before connecting-v
outputs command ouput to the screen-m
specifies the module to be used- The
raw
module is not the only way to run ansible commands without a playbook
ansible sw3 -v -i inventory.ini -k -K -m raw -a "ping 4.2.2.2"