Appendix
Articles » Yet Another Network Automation Journey » Appendix
EEM Scripts
Cisco IOS EEM script that creates missing SSH keys on router reboot
event manager applet EEM_SSH_Keygen
event timer cron cron-entry "@reboot"
action 0.0 info type routername
action 0.1 set status "none"
action 1.0 cli command "enable"
action 2.0 cli command "show ip ssh | include ^SSH"
action 2.1 regexp "([ED][^ ]+)" "$_cli_result" result status
action 3.0 if $status eq Disabled
action 3.1 cli command "configure terminal"
action 3.2 cli command "crypto key generate rsa mod 2048 label $_info_routername"
action 3.3 cli command "end"
action 3.4 end
Source: https://community.cisco.com/t5/network-management/create-rsa-keys-if-they-do-not-exist/td-p/2614667.
Archive download-sw Options
# archive download-sw ?
/allow-feature-upgrade Allow installation of image with different feature sets
/directory Specify a directory for images
/force-reload Unconditionally reload system after successful sw upgrade
/force-ucode-reload Upgrade UCODE after successful sw upgrade and before
an unconditional reload
/imageonly Load only the IOS image(s)
/leave-old-sw Leave old sw installed after successful sw upgrade
/no-set-boot Don't set BOOT -- leave existing boot config alone
/no-version-check skip version check that prevents incompatible image install
/overwrite OK to overwrite an existing image
/reload Reload system (if no unsaved config changes) after
successful sw upgrade
/safe Always load before deleting old version
/upgrade-ucode Upgrade UCODE after successful sw upgrade (no reload)
Formatting Ansible Playbook Outputs
Output generated by ansible-playbook can be formatted using
callback plugins included
in Ansible distribution. The selective callback is particularly useful, as it allows
you to control what is displayed with the tags: [ print_action ]
attribute. Unfortunately,
it outputs additional codes for formatting and colorizing the output.
I ended up working around this by copying selective.py to the directory callback_plugins
in the playbook directory, editing it, and changing return msg
to:
if DONT_COLORIZE:
return msg.encode('utf-8')
The environment variable ANSIBLE_SELECTIVE_DONT_COLORIZE can now be used to toggle the formatting of output messages, greatly enhancing the readability of the Ansible output in a web browser. I am now playing with outputting HTML text where each output category (‘changed’, ‘failed’, ‘skipped’, etc.) is mapped to its own CSS div class.

Ansible playbook output
This article is an account of how to get started with network automation, and some common use cases. You can reach Anne via LinkedIn.