Chapter 6 Network Reconnaissance

For diagrams, tables, or exact code formatting, .

JOHN W. CAPOBIANCOPRINTED PAGE 104
changed: [ACCESS02] 
changed: [ACCESS03]  
 
PLAY RECAP**************************************************************************** 
CORE                       : ok=2    changed=1    unreachable=0    failed=0 
DIST01                     : ok=2    changed=1    unreachable=0    failed=0 
DIST02                     : ok=2    changed=1    unreachable=0    failed=0 
ACCESS01                   : ok=2    changed=1    unreachable=0    failed=0 
ACCESS02                   : ok=2    changed=1    unreachable=0    failed=0 
ACCESS03                   : ok=2    changed=1    unreachable=0    failed=0 
 
When the playbook has completed successfully, use Git to save, commit, comment, and push the 
resulting output files into the repository.

Git add * Git commit –a Add comments using the VI editor, press (ESC), type (:wq) to save and exit VI. Git push Enter TFS credentials. Refresh the VS Code editor / git pull from the command palette. Or visit TFS and view the output through the TFS file explorer. There will now be a .txt file for each device containing the running- configuration of the device. A sample of the output is below:

{"failed": false, "changed": false, "stdout_lines": [["Building configuration...", "", 
"Current configuration : 18620 bytes", "!", "! Last configuration change at 12:37:13 EDT 
Thu Aug 2 2018 by automateyournetwork", "! NVRAM config last updated at 14:06:39 EDT Fri 
Oct 12 2018 by automateyournetwork", "!", "version 15.2", "no service pad", "service tcp-
keepalives-in", "service tcp-keepalives-out", "service timestamps debug datetime msec 
localtime", "service timestamps log datetime msec localtime", "service password-
encryption", "service compress-config", "service counters max age 5", "!", "hostname 
DIST01"

While having the ability to gather every device’s running-configuration is incredibly powerful the default formatting of the output makes it difficult to consume. We can transform this output to the standard human-readable running-configuration using an Ansible filter.

Limit the output to the standard output lines (stdout_line) and change the output format to be nice_to_yaml. This will improve the readability of the running-configuration output.

Edit the following line in the ios_command_running_configuration.yml: 
 
- copy:  
   content="{{ show_run_output }}"  
   dest="./results/{{ inventory_hostname }}_running_config.txt" 
 
To modify the output format:  
 
- copy:  
   content="{{ show_run_output.stdout_line | nice_to_yaml }}"