Advertisement
cbiswas16

Untitled

Dec 8th, 2019
371
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 2.48 KB | None | 0 0
  1. ---
  2. - name: CONFIGURE CISCO ROUTERS
  3.   hosts: router_bdnog11
  4.   gather_facts: no
  5.   connection: local
  6.  
  7.   tasks:
  8.    - name: OBTAIN LOGIN INFORMATION
  9.      include_vars: secrets.yml
  10.  
  11.    - name: DEFINE PROVIDER
  12.      set_fact:
  13.        provider:
  14.          host: "{{ ansible_host }}"
  15.          username: "{{ creds['username'] }}"
  16.          password: "{{ creds['password'] }}"
  17.          auth_pass: "{{ creds['auth_pass'] }}"
  18.  
  19.    - name: BASIC CONFIGURATION
  20.      ios_config:
  21.        provider: "{{ provider }}"
  22.        authorize: yes
  23.        lines:
  24.         - aaa new-model
  25.          - aaa authentication login default local
  26.          - aaa authentication enable default enable
  27.          - no logging console
  28.          - no ip domain-lookup
  29.          - ipv6 unicast-routing
  30.          - ipv6 cef
  31.          - no ip source-route
  32.          - no ipv6 source-route
  33.          - snmp-server community C-DAC RO 99
  34.          - ntp server 192.168.0.250
  35.  
  36.  
  37.    - name: CONFIGURE INTERFACE SETTINGS
  38.      ios_config:
  39.        provider: "{{ provider }}"
  40.        authorize: yes
  41.        parents: interface FastEthernet2/0
  42.        lines:
  43.         - description Test Interface
  44.          - ip address 172.31.1.1 255.255.255.252
  45.          - ipv6 address 2001:db8:8::9/64
  46.          - no shutdown
  47.  
  48.    - name: ALL-DENY PREFIX LIST
  49.      ios_config:
  50.        provider: "{{ provider }}"
  51.        authorize: yes
  52.        lines:
  53.         - ip prefix-list ALL-DENY seq 5 deny 0.0.0.0/0 le 32
  54.  
  55.  
  56.    - name: PUSH THE POLICY to DEVICE
  57.      ios_config:
  58.        provider: "{{ provider }}"
  59.        authorize: yes
  60.        src: CUSTOMER-1.txt
  61.  
  62.  
  63.    - name: BGP CONFIGURATION
  64.      ios_config:
  65.        provider: "{{ provider }}"
  66.        authorize: yes
  67.        parents: router bgp 10075
  68.        lines:
  69.         - neighbor 172.31.1.2 remote-as 63996
  70.          - neighbor 172.31.1.2 description TEST-BGP
  71.          - neighbor 172.31.1.2 activate
  72.          - neighbor 172.31.1.2 prefix-list AS63996-Prefix in
  73.          - neighbor 172.31.1.2 prefix-list ALL-DENY out
  74.  
  75.  
  76.    - name: SAVE CONFIGURATION TO NVRAM
  77.      ios_config:
  78.        provider: "{{ provider }}"
  79.        authorize: yes
  80.        save_when: always
  81.      register: output
  82.  
  83.    
  84. - name: SHOW RUN COMMAND
  85.      ios_command:
  86.        provider: "{{ provider }}"
  87.        authorize: yes
  88.        commands: show run
  89.      register: print_output
  90.  
  91.    - name: SAVE OUTPUT TO A FILE
  92.      copy: content="{{print_output.stdout[0]}}" dest="/home/gns3/inventory/backup-configuration/{{inventory_hostname}}.txt"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement