Bookmark this page

Guided Exercise: Provisioning the Start-up Network

In the start-up phase of example.com, their first network device has just been provisioned: a CSR1000V router. This is the cs01 device. The new router is hosted with a cloud services provider (CSP). The act of provisioning it brings it online with a connection to the internet on interface GigabitEthernet1.

The first production application server has been provisioned. The server is named server03. The eth1 interface of this server is connected to vlan1 on a switch belonging to the CSP. The GigabitEthernet4 interface on cs01 is connected to the same VLAN and switch.

During this phase, the Production Services Network of example.com consists of one network device, cs01, which has a server connected to it.

Jasper asks you to compose a playbook that will:

  1. Apply the interface description outside to the outside interface, GigabitEthernet1.

  2. Configure layer 3 on the inside interface, GigabitEthernet4

  3. Apply the interface description inside to the inside interface, GigabitEthernet4.

  4. Bounce the inside interface.

  5. Verify that the new server, server03, is reachable from cs01 after bringing up the inside interface.

You will access the device by way of the GigabitEthernet1 interface. This interface is already configured with respect to layer 3 and up. It is considered the outside interface.

Figure 5.2:

The start-up phase Production Services Network of example.com.

Table 5.1. Start-up Phase Interface Descriptions

Device Interface Description
cs01 GigabitEthernet1 outside
cs01 GigabitEthernet4 inside

Table 5.2. Start-up Phase Layer 3 Addressing (management network not shown)

Device Interface Description
cs01 Loopback1 172.16.0.1/32
cs01 GigabitEthernet4 172.16.10.1/30

In this exercise, you will provision the example.com Production Services Network that corresponds to the start-up phase.

Outcomes

You should be able to:

  • Create a vars file defining the variables that will be used.

  • Compose a playbook with a play that satisfies the business requirements as stated by Jasper.

  • Perform the play in the playbook to enact the desired changes.

  • Verify that the outcome is as intended.

Open a terminal window on the workstation VM and change to the ~/proj/ directory.

  1. Create a vars file defining the variables that will be used.

    1. Create a vars file named vars/startup-data.yml that defines a layer3_data variable and an interface_data variable as shown here:

      layer3_data:
        cs01:
          - { name: Loopback1, ipv4: 172.16.0.1/32 }
          - { name: GigabitEthernet4, ipv4: 172.16.10.1/30 }
      
      interface_data:
        cs01:
          GigabitEthernet1:
            description: outside
          GigabitEthernet4:
            description: inside
  2. Compose a playbook with a play that satisfies the business requirements as stated by Jasper.

    1. Create a playbook named startup.yml as shown here:

      ---
      - name: define the startup example.com layer3 network
        hosts: cs01
        vars:
          mgmt_intf: GigabitEthernet1
          server_ipv4: 172.16.10.2/30
        vars_files:
          - vars/startup-data.yml
      
        tasks:
      
        - name: remove old layer3 interface data
          ios_l3_interface:
            aggregate: "{{ layer3_data[inventory_hostname] }}"
            state: absent
      
        - name: configure layer3 interfaces
          ios_l3_interface:
            aggregate: "{{ layer3_data[inventory_hostname] }}"
      
        - name: configure description of management interface
          # do management interface separately, do not shut down
          ios_interface:
            name: "{{ mgmt_intf }}"
            description: >
             {{ interface_data[inventory_hostname][mgmt_intf].description }}
      
        - name: configure interface description
          ios_interface:
            name: "{{ item.key }}"
            description: "{{ item.value.description }}"
            enabled: no
          when: not item.key == mgmt_intf
          with_dict: "{{ interface_data[inventory_hostname] }}"
      
        - name: bring interfaces up
          ios_interface:
            name: "{{ item.key }}"
            enabled: yes
          when: not item.key == mgmt_intf
          with_dict: "{{ interface_data[inventory_hostname] }}"
      
        - name: pause
          pause:
            seconds: 1
      
        - name: test connectivity to server
          ios_ping:
            dest: "{{ server_ipv4 | ipaddr('address') }}"
          register: result
      
        - name: show result
          debug:
            var: result
  3. Perform the play in the playbook to enact the desired changes.

    [student@workstation proj]$ ansible-playbook startup.yml
  4. Execute ad hoc commands and verify that layer 3 addresses are mapped to interfaces as described in the tables found at the start of this exercise. Only one networking device appears in the Start Up scenario: cs01. Here the syntax of the command is shown for use with cs01:

    [student@workstation proj]$ ansible -m ios_command \
    > -a "commands='sh ip int br'" cs01

This concludes the guided exercise.

Revision: do457-2.5-4693601