Chapter 6 Network Reconnaissance
For diagrams, tables, or exact code formatting, .
JOHN W. CAPOBIANCOPRINTED PAGE 105
dest="./results/{{ inventory_hostname }}_running_config.txt"
Re-run the Ansible playbook.
[automateyournetworkj@LINUX HOST]$ ansible-playbook ios_running_config.yml
Now a human-readable version is included in output file.
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
Submit a pull request and proceed with the change management process merging into the master
branch and then deleting the working branch.Here is another ios_command example: Repeat the same outlined NDLC process: add work to the board; mark it as active; create a working branch; refresh local repository / VS Code / Linux via git pull; change to working branch.
Create a reconnaissance playbook called ios_command_ospfneighbors.yml.
---
- hosts: CAMPUS-DIST
tasks:
- name: run show ospf neighbors
ios_command:
commands: show ip ospf neighbor
provider: "{{ ioscli }}"
register: ospfneighbor_result
- set_fact: ospfneighbor={{ ospfneighbor_result.stdout_lines | to_nice_yaml }}
- name: create log file for all devices
file: path=./results/running_config/{{ inventory_hostname }}.all.txt
state=touchcheck_mode: no
- name: log to file for all devices
lineinfile:
insertafter: EOF
path: ./results/running_config/{{ inventory_hostname }}.all.txt