Chapter 7 Tactical Playbooks

For diagrams, tables, or exact code formatting, .

JOHN W. CAPOBIANCOPRINTED PAGE 117

Provision of a VLAN Earlier in the chapter we discussed the steps required to orchestrate the provisioning of a VLAN. Here we will convert that intent and the manual steps into a fully orchestrated playbook that will provision the VLAN as a service setting up both the distribution and access side of the network. A reminder of the intent:

 Distribution layer:

o New VLAN. o STP root for new VLAN. o New SVI for VLAN. o Add VLAN to port-channel facing access switch.

 Access layer:

o New VLAN.  
o Add VLAN to port-channel facing distribution layer.  
o Configure physical interfaces as access ports on new VLAN. 
 
--- 
 
- hosts: DIST01 
  tasks: 
  - name: Create VLAN on DIST01  
    ios_config: 
      lines: 
        -  vlan 10 
        -  name GREEN_VLAN_FIRST_FLOOR 
        -  spanning-tree vlan 10 root primary  
      provider: "{{ ioscli }}" 
 
- hosts: DIST01 
  tasks: 
  - name: Add VLAN to Port-Channel 2 on DIST01 
    ios_config: 
      lines: 
        -  switchport trunk allowed vlan add 10 
      parents: interface Port-channel2 
      provider: "{{ ioscli }}" 
 
- hosts: DIST01 
  tasks: 
  - name: Copy running-config to startup-config on DIST01  
    ios_command: 
      lines: 
        -  copy run start 
      provider: "{{ ioscli }}" 
 
- hosts: ACCESS01 
  tasks: 
  - name: Create VLAN on ACCESS01 
    ios_config: