[WARNING]: Could not match supplied host pattern, ignoring: unprovisioned PLAY [Deploy initial device configuration] ************************************* TASK [Set variables that cannot be set with VARS] ****************************** ok: [s2] ok: [s4] ok: [s3] ok: [d1] ok: [d2] ok: [d3] ok: [d4] ok: [r1] ok: [r2] ok: [r3] ok: [r4] ok: [s1] TASK [Find device readiness script] ******************************************** ok: [s2] ok: [s3] ok: [s4] ok: [d2] ok: [d1] ok: [d3] ok: [d4] ok: [r2] ok: [r1] ok: [r3] ok: [r4] ok: [s1] TASK [Wait for device to become ready] ***************************************** skipping: [s2] skipping: [s3] skipping: [s4] skipping: [d1] skipping: [d2] skipping: [d3] skipping: [d4] skipping: [r1] skipping: [r2] skipping: [r3] skipping: [r4] skipping: [s1] TASK [Normalize config on bridge-like devices] ********************************* included: /home/pipi/net101/tools/netsim/ansible/tasks/deploy-module.yml for s2, s3, s4, d1, d2, d3, d4, r1, r2, r3, r4, s1 TASK [Figure out whether to deploy the module normalize on current device] ***** ok: [s3] ok: [s2] ok: [s4] ok: [d1] ok: [d2] ok: [d3] ok: [r1] ok: [d4] ok: [r2] ok: [r3] ok: [r4] ok: [s1] TASK [Find configuration template for normalize] ******************************* ok: [s2] ok: [s3] ok: [s4] ok: [d2] ok: [d1] ok: [d4] ok: [d3] ok: [r2] ok: [r1] ok: [r3] ok: [r4] ok: [s1] TASK [fail] ******************************************************************** skipping: [s2] skipping: [s3] skipping: [s4] skipping: [d1] skipping: [d2] skipping: [d3] skipping: [d4] skipping: [r1] skipping: [r2] skipping: [r3] skipping: [r4] skipping: [s1] TASK [Print deployed configuration when running in verbose mode] *************** skipping: [s2] skipping: [s3] skipping: [s4] skipping: [d1] skipping: [d2] skipping: [d3] skipping: [d4] skipping: [r1] skipping: [r2] skipping: [r3] skipping: [r4] ok: [s1] => msg: |- normalize configuration for s1 ========================================= ! interface GigabitEthernet0/1 shutdown mac-address 52dc.cafe.0101 ! interface GigabitEthernet0/2 shutdown mac-address 52dc.cafe.0102 ! interface GigabitEthernet0/3 shutdown mac-address 52dc.cafe.0103 ! interface GigabitEthernet1/0 shutdown mac-address 52dc.cafe.0104 ! interface GigabitEthernet1/1 shutdown mac-address 52dc.cafe.0105 TASK [Find configuration deployment deploy_script for normalize] *************** skipping: [s2] skipping: [s3] skipping: [s4] skipping: [d1] skipping: [d2] skipping: [d3] skipping: [d4] skipping: [r1] skipping: [r2] skipping: [r3] skipping: [r4] ok: [s1] TASK [Deploy normalize configuration] ****************************************** skipping: [s2] skipping: [s3] skipping: [s4] skipping: [d1] skipping: [d2] skipping: [d3] skipping: [d4] skipping: [r1] skipping: [r2] skipping: [r3] skipping: [r4] included: /home/pipi/net101/tools/netsim/ansible/tasks/deploy-config/ios.yml for s1 TASK [ios_config: deploying normalize from /home/pipi/net101/tools/netsim/ansible/templates/normalize/iosvl2.j2] *** [WARNING]: To ensure idempotency and correct diff the input configuration lines should be similar to how they appear if present in the running configuration on device including the indentation changed: [s1] TASK [Deploy initial configuration] ******************************************** included: /home/pipi/net101/tools/netsim/ansible/tasks/deploy-module.yml for s2, s3, s4, d1, d2, d3, d4, r1, r2, r3, r4, s1 TASK [Figure out whether to deploy the module initial on current device] ******* ok: [s2] ok: [s3] ok: [s4] ok: [d1] ok: [d2] ok: [d4] ok: [d3] ok: [r1] ok: [r2] ok: [r3] ok: [r4] ok: [s1] TASK [Find configuration template for initial] ********************************* ok: [s2] ok: [s3] ok: [s4] ok: [d1] ok: [d2] ok: [d4] ok: [d3] ok: [r2] ok: [r1] ok: [r4] ok: [r3] ok: [s1] TASK [fail] ******************************************************************** skipping: [s2] skipping: [s3] skipping: [s4] skipping: [d1] skipping: [d2] skipping: [d3] skipping: [d4] skipping: [r1] skipping: [r2] skipping: [r3] skipping: [r4] skipping: [s1] TASK [Print deployed configuration when running in verbose mode] *************** ok: [d1] => msg: |- initial configuration for d1 ========================================= #!/bin/bash # # This script contains the 'ip' commands needed to set up container # interfaces and route table. It's executed within the container # network namespace on the container host. # # /etc/hosts file is generated as a clab bind. # set -e ### One-Shot configuration (non-Ubuntu VM or container) # # Disable IPv4 and IPv6 forwarding # sysctl -w net.ipv4.ip_forward=0 sysctl -w net.ipv6.conf.all.forwarding=0 # # Interface addressing, create any bond devices # ip link set dev eth1 up set +e ip addr del 172.31.1.9/24 dev eth1 2>/dev/null set -e ip addr add 172.31.1.9/24 dev eth1 ip link set dev eth1 mtu 1500 # # Add static routes (usually IPv4 routes pointing to the first usable gateway) # echo Removing existing IPv4 routes while ip route del 172.16.0.0/16 2>/dev/null; do : ; done while ip route del 10.0.0.0/24 2>/dev/null; do : ; done while ip route del 10.1.0.0/16 2>/dev/null; do : ; done while ip route del 10.2.0.0/24 2>/dev/null; do : ; done # # echo Adding direct static routes ip route add 172.16.0.0/16 via 172.31.1.1 dev eth1 protocol static ip route add 10.0.0.0/24 via 172.31.1.1 dev eth1 protocol static ip route add 10.1.0.0/16 via 172.31.1.1 dev eth1 protocol static ip route add 10.2.0.0/24 via 172.31.1.1 dev eth1 protocol static # # Print the final routing table ip route ok: [d2] => msg: |- initial configuration for d2 ========================================= #!/bin/bash # # This script contains the 'ip' commands needed to set up container # interfaces and route table. It's executed within the container # network namespace on the container host. # # /etc/hosts file is generated as a clab bind. # set -e ### One-Shot configuration (non-Ubuntu VM or container) # # Disable IPv4 and IPv6 forwarding # sysctl -w net.ipv4.ip_forward=0 sysctl -w net.ipv6.conf.all.forwarding=0 # # Interface addressing, create any bond devices # ip link set dev eth1 up set +e ip addr del 172.31.1.10/24 dev eth1 2>/dev/null set -e ip addr add 172.31.1.10/24 dev eth1 ip link set dev eth1 mtu 1500 # # Add static routes (usually IPv4 routes pointing to the first usable gateway) # echo Removing existing IPv4 routes while ip route del 172.16.0.0/16 2>/dev/null; do : ; done while ip route del 10.0.0.0/24 2>/dev/null; do : ; done while ip route del 10.1.0.0/16 2>/dev/null; do : ; done while ip route del 10.2.0.0/24 2>/dev/null; do : ; done # # echo Adding direct static routes ip route add 172.16.0.0/16 via 172.31.1.2 dev eth1 protocol static ip route add 10.0.0.0/24 via 172.31.1.2 dev eth1 protocol static ip route add 10.1.0.0/16 via 172.31.1.2 dev eth1 protocol static ip route add 10.2.0.0/24 via 172.31.1.2 dev eth1 protocol static # # Print the final routing table ip route ok: [d3] => msg: |- initial configuration for d3 ========================================= #!/bin/bash # # This script contains the 'ip' commands needed to set up container # interfaces and route table. It's executed within the container # network namespace on the container host. # # /etc/hosts file is generated as a clab bind. # set -e ### One-Shot configuration (non-Ubuntu VM or container) # # Disable IPv4 and IPv6 forwarding # sysctl -w net.ipv4.ip_forward=0 sysctl -w net.ipv6.conf.all.forwarding=0 # # Interface addressing, create any bond devices # ip link set dev eth1 up set +e ip addr del 172.31.1.11/24 dev eth1 2>/dev/null set -e ip addr add 172.31.1.11/24 dev eth1 ip link set dev eth1 mtu 1500 # # Add static routes (usually IPv4 routes pointing to the first usable gateway) # echo Removing existing IPv4 routes while ip route del 172.16.0.0/16 2>/dev/null; do : ; done while ip route del 10.0.0.0/24 2>/dev/null; do : ; done while ip route del 10.1.0.0/16 2>/dev/null; do : ; done while ip route del 10.2.0.0/24 2>/dev/null; do : ; done # # echo Adding direct static routes ip route add 172.16.0.0/16 via 172.31.1.3 dev eth1 protocol static ip route add 10.0.0.0/24 via 172.31.1.3 dev eth1 protocol static ip route add 10.1.0.0/16 via 172.31.1.3 dev eth1 protocol static ip route add 10.2.0.0/24 via 172.31.1.3 dev eth1 protocol static # # Print the final routing table ip route ok: [d4] => msg: |- initial configuration for d4 ========================================= #!/bin/bash # # This script contains the 'ip' commands needed to set up container # interfaces and route table. It's executed within the container # network namespace on the container host. # # /etc/hosts file is generated as a clab bind. # set -e ### One-Shot configuration (non-Ubuntu VM or container) # # Disable IPv4 and IPv6 forwarding # sysctl -w net.ipv4.ip_forward=0 sysctl -w net.ipv6.conf.all.forwarding=0 # # Interface addressing, create any bond devices # ip link set dev eth1 up set +e ip addr del 172.31.1.12/24 dev eth1 2>/dev/null set -e ip addr add 172.31.1.12/24 dev eth1 ip link set dev eth1 mtu 1500 # # Add static routes (usually IPv4 routes pointing to the first usable gateway) # echo Removing existing IPv4 routes while ip route del 172.16.0.0/16 2>/dev/null; do : ; done while ip route del 10.0.0.0/24 2>/dev/null; do : ; done while ip route del 10.1.0.0/16 2>/dev/null; do : ; done while ip route del 10.2.0.0/24 2>/dev/null; do : ; done # # echo Adding direct static routes ip route add 172.16.0.0/16 via 172.31.1.4 dev eth1 protocol static ip route add 10.0.0.0/24 via 172.31.1.4 dev eth1 protocol static ip route add 10.1.0.0/16 via 172.31.1.4 dev eth1 protocol static ip route add 10.2.0.0/24 via 172.31.1.4 dev eth1 protocol static # # Print the final routing table ip route ok: [r1] => msg: |- initial configuration for r1 ========================================= #!/bin/bash # # This script contains the 'ip' commands needed to set up container # interfaces and route table. It's executed within the container # network namespace on the container host. # # /etc/hosts file is generated as a clab bind. # set -e ### One-Shot configuration (non-Ubuntu VM or container) # # Disable IPv4 and IPv6 forwarding # sysctl -w net.ipv4.ip_forward=0 sysctl -w net.ipv6.conf.all.forwarding=0 # # Interface addressing, create any bond devices # ip link set dev eth1 up set +e ip addr del 172.31.1.5/24 dev eth1 2>/dev/null set -e ip addr add 172.31.1.5/24 dev eth1 ip link set dev eth1 mtu 1500 # # Add static routes (usually IPv4 routes pointing to the first usable gateway) # # # # # Print the final routing table ip route ok: [r2] => msg: |- initial configuration for r2 ========================================= #!/bin/bash # # This script contains the 'ip' commands needed to set up container # interfaces and route table. It's executed within the container # network namespace on the container host. # # /etc/hosts file is generated as a clab bind. # set -e ### One-Shot configuration (non-Ubuntu VM or container) # # Disable IPv4 and IPv6 forwarding # sysctl -w net.ipv4.ip_forward=0 sysctl -w net.ipv6.conf.all.forwarding=0 # # Interface addressing, create any bond devices # ip link set dev eth1 up set +e ip addr del 172.31.1.6/24 dev eth1 2>/dev/null set -e ip addr add 172.31.1.6/24 dev eth1 ip link set dev eth1 mtu 1500 # # Add static routes (usually IPv4 routes pointing to the first usable gateway) # # # # # Print the final routing table ip route ok: [s2] => msg: |- initial configuration for s2 ========================================= #!/bin/bash # set -e set -x # # Create bash profile script # cat <<SCRIPT >/root/.bash_profile #!/bin/bash # export PS1="\h(bash)# " echo echo "Use vtysh to connect to FRR daemon" echo SCRIPT cat <<SCRIPT >.bash_profile #!/bin/bash # export PS1="\h(bash)$ " export PATH=$PATH:/usr/sbin echo echo "Use sudo vtysh to connect to FRR daemon" echo SCRIPT # # Build hosts file # # cat <<SCRIPT >/tmp/hosts # # Created by netlab initial # 10.0.0.2 s2 172.31.1.2 vlan1.s2 10.0.0.3 s3 172.31.1.3 vlan1.s3 10.0.0.4 s4 172.31.1.4 vlan1.s4 172.31.1.9 d1 eth1.d1 172.31.1.10 d2 eth1.d2 172.31.1.11 d3 eth1.d3 172.31.1.12 d4 eth1.d4 172.31.1.5 r1 eth1.r1 172.31.1.6 r2 eth1.r2 172.31.1.7 r3 eth1.r3 172.31.1.8 r4 eth1.r4 10.0.0.1 s1 172.31.1.1 Vlan1.s1 SCRIPT grep "Created by netlab" /etc/hosts || uniq /tmp/hosts >>/etc/hosts # # Configure system defaults on Ubuntu # hostnamectl set-hostname s2 sysctl -w net.ipv4.ip_forward=1 sysctl -w net.ipv6.conf.all.forwarding=1 APT_INSTALL= # if which curl; then echo "Package curl already installed" else APT_INSTALL="$APT_INSTALL curl" fi # if which gpg; then echo "Package gnupg already installed" else APT_INSTALL="$APT_INSTALL gnupg" fi # if which bridge; then echo "Package iproute2 already installed" else APT_INSTALL="$APT_INSTALL iproute2" fi # # APT_INSTALL always starts with a blank, so we can't just check if it's empty # The following hack turns a string that contains only whitespaces into # an empty string and removes leading whitespaces # APT_INSTALL=`echo $APT_INSTALL` if [ -n "$APT_INSTALL" ]; then echo "Installing packages $APT_INSTALL" apt-get update -qq && apt-get install -qq $APT_INSTALL fi # # Install FRR on a Ubuntu VM if needed # if which /usr/lib/frr/frrinit.sh; then echo "FRR already installed, skipping installation" else curl -s https://deb.frrouting.org/frr/keys.asc >/etc/apt/trusted.gpg.d/frr.asc FRRVER="frr-stable" echo deb https://deb.frrouting.org/frr $(lsb_release -s -c) $FRRVER > /etc/apt/sources.list.d/frr.list apt-get update -qq && apt-get install -qq frr frr-pythontools bridge-utils ethtool fi # # Enable FRR modules (if not using containerlab bind-mounted /etc/frr/daemons) # # # Enable FRR daemons # /usr/lib/frr/frrinit.sh restart # # Create loopbacks, stub and lag/bond devices # if [ ! -e /sys/class/net/lo ]; then if [ ! -e /sys/devices/virtual/net/lo ]; then ip link add lo type dummy ip link set dev lo up fi fi # Disable IPv6 (for IPv4-only interfaces) or SLAAC (if the device is a router) # sysctl -qw net.ipv6.conf.eth1.disable_ipv6=1 ip link set dev eth1 mtu 1500 sysctl -qw net.ipv6.conf.eth2.disable_ipv6=1 ip link set dev eth2 mtu 1500 sysctl -qw net.ipv6.conf.eth3.disable_ipv6=1 ip link set dev eth3 mtu 1500 # # Add vtysh.conf file echo "service integrated-vtysh-config" >/etc/frr/vtysh.conf # # Rest of initial configuration done through VTYSH # cat >/tmp/config <<CONFIG hostname s2 ! frr defaults datacenter ! interface lo no shutdown ip address 10.0.0.2/32 ! interface eth1 no shutdown description s2 -> s1 ! no ip address ! interface eth2 no shutdown description [Access VLAN red] s2 -> r2 ! no ip address ! interface eth3 no shutdown description [Access VLAN vlan_1] s2 -> d2 ! no ip address ! interface eth1.700 no shutdown description [SubIf VLAN red] s2 -> s1 ! no ip address ! interface eth1.1 no shutdown description [SubIf VLAN vlan_1] s2 -> s1 ! no ip address ! interface vlan700 no shutdown description VLAN red (700) -> [s4,s1,r1,s3,r2...] ! no ip address ! interface vlan1 no shutdown description VLAN vlan_1 (1) -> [s3,s1,d1,s4,d2...] ip address 172.31.1.2/24 ! do write CONFIG vtysh -f /tmp/config exit 0 ok: [r3] => msg: |- initial configuration for r3 ========================================= #!/bin/bash # # This script contains the 'ip' commands needed to set up container # interfaces and route table. It's executed within the container # network namespace on the container host. # # /etc/hosts file is generated as a clab bind. # set -e ### One-Shot configuration (non-Ubuntu VM or container) # # Disable IPv4 and IPv6 forwarding # sysctl -w net.ipv4.ip_forward=0 sysctl -w net.ipv6.conf.all.forwarding=0 # # Interface addressing, create any bond devices # ip link set dev eth1 up set +e ip addr del 172.31.1.7/24 dev eth1 2>/dev/null set -e ip addr add 172.31.1.7/24 dev eth1 ip link set dev eth1 mtu 1500 # # Add static routes (usually IPv4 routes pointing to the first usable gateway) # # # # # Print the final routing table ip route ok: [r4] => msg: |- initial configuration for r4 ========================================= #!/bin/bash # # This script contains the 'ip' commands needed to set up container # interfaces and route table. It's executed within the container # network namespace on the container host. # # /etc/hosts file is generated as a clab bind. # set -e ### One-Shot configuration (non-Ubuntu VM or container) # # Disable IPv4 and IPv6 forwarding # sysctl -w net.ipv4.ip_forward=0 sysctl -w net.ipv6.conf.all.forwarding=0 # # Interface addressing, create any bond devices # ip link set dev eth1 up set +e ip addr del 172.31.1.8/24 dev eth1 2>/dev/null set -e ip addr add 172.31.1.8/24 dev eth1 ip link set dev eth1 mtu 1500 # # Add static routes (usually IPv4 routes pointing to the first usable gateway) # # # # # Print the final routing table ip route ok: [s4] => msg: |- initial configuration for s4 ========================================= #!/bin/bash # set -e set -x # # Create bash profile script # cat <<SCRIPT >/root/.bash_profile #!/bin/bash # export PS1="\h(bash)# " echo echo "Use vtysh to connect to FRR daemon" echo SCRIPT cat <<SCRIPT >.bash_profile #!/bin/bash # export PS1="\h(bash)$ " export PATH=$PATH:/usr/sbin echo echo "Use sudo vtysh to connect to FRR daemon" echo SCRIPT # # Build hosts file # # cat <<SCRIPT >/tmp/hosts # # Created by netlab initial # 10.0.0.2 s2 172.31.1.2 vlan1.s2 10.0.0.3 s3 172.31.1.3 vlan1.s3 10.0.0.4 s4 172.31.1.4 vlan1.s4 172.31.1.9 d1 eth1.d1 172.31.1.10 d2 eth1.d2 172.31.1.11 d3 eth1.d3 172.31.1.12 d4 eth1.d4 172.31.1.5 r1 eth1.r1 172.31.1.6 r2 eth1.r2 172.31.1.7 r3 eth1.r3 172.31.1.8 r4 eth1.r4 10.0.0.1 s1 172.31.1.1 Vlan1.s1 SCRIPT grep "Created by netlab" /etc/hosts || uniq /tmp/hosts >>/etc/hosts # # Configure system defaults on Ubuntu # hostnamectl set-hostname s4 sysctl -w net.ipv4.ip_forward=1 sysctl -w net.ipv6.conf.all.forwarding=1 APT_INSTALL= # if which curl; then echo "Package curl already installed" else APT_INSTALL="$APT_INSTALL curl" fi # if which gpg; then echo "Package gnupg already installed" else APT_INSTALL="$APT_INSTALL gnupg" fi # if which bridge; then echo "Package iproute2 already installed" else APT_INSTALL="$APT_INSTALL iproute2" fi # # APT_INSTALL always starts with a blank, so we can't just check if it's empty # The following hack turns a string that contains only whitespaces into # an empty string and removes leading whitespaces # APT_INSTALL=`echo $APT_INSTALL` if [ -n "$APT_INSTALL" ]; then echo "Installing packages $APT_INSTALL" apt-get update -qq && apt-get install -qq $APT_INSTALL fi # # Install FRR on a Ubuntu VM if needed # if which /usr/lib/frr/frrinit.sh; then echo "FRR already installed, skipping installation" else curl -s https://deb.frrouting.org/frr/keys.asc >/etc/apt/trusted.gpg.d/frr.asc FRRVER="frr-stable" echo deb https://deb.frrouting.org/frr $(lsb_release -s -c) $FRRVER > /etc/apt/sources.list.d/frr.list apt-get update -qq && apt-get install -qq frr frr-pythontools bridge-utils ethtool fi # # Enable FRR modules (if not using containerlab bind-mounted /etc/frr/daemons) # # # Enable FRR daemons # /usr/lib/frr/frrinit.sh restart # # Create loopbacks, stub and lag/bond devices # if [ ! -e /sys/class/net/lo ]; then if [ ! -e /sys/devices/virtual/net/lo ]; then ip link add lo type dummy ip link set dev lo up fi fi # Disable IPv6 (for IPv4-only interfaces) or SLAAC (if the device is a router) # sysctl -qw net.ipv6.conf.eth1.disable_ipv6=1 ip link set dev eth1 mtu 1500 sysctl -qw net.ipv6.conf.eth2.disable_ipv6=1 ip link set dev eth2 mtu 1500 sysctl -qw net.ipv6.conf.eth3.disable_ipv6=1 ip link set dev eth3 mtu 1500 # # Add vtysh.conf file echo "service integrated-vtysh-config" >/etc/frr/vtysh.conf # # Rest of initial configuration done through VTYSH # cat >/tmp/config <<CONFIG hostname s4 ! frr defaults datacenter ! interface lo no shutdown ip address 10.0.0.4/32 ! interface eth1 no shutdown description s4 -> s1 ! no ip address ! interface eth2 no shutdown description [Access VLAN red] s4 -> r4 ! no ip address ! interface eth3 no shutdown description [Access VLAN vlan_1] s4 -> d4 ! no ip address ! interface eth1.1 no shutdown description [SubIf VLAN vlan_1] s4 -> s1 ! no ip address ! interface vlan700 no shutdown description VLAN red (700) -> [s1,r1,s2,s3,r2...] ! no ip address ! interface vlan1 no shutdown description VLAN vlan_1 (1) -> [s3,s1,d1,s2,d2...] ip address 172.31.1.4/24 ! do write CONFIG vtysh -f /tmp/config exit 0 ok: [s3] => msg: |- initial configuration for s3 ========================================= #!/bin/bash # set -e set -x # # Create bash profile script # cat <<SCRIPT >/root/.bash_profile #!/bin/bash # export PS1="\h(bash)# " echo echo "Use vtysh to connect to FRR daemon" echo SCRIPT cat <<SCRIPT >.bash_profile #!/bin/bash # export PS1="\h(bash)$ " export PATH=$PATH:/usr/sbin echo echo "Use sudo vtysh to connect to FRR daemon" echo SCRIPT # # Build hosts file # # cat <<SCRIPT >/tmp/hosts # # Created by netlab initial # 10.0.0.2 s2 172.31.1.2 vlan1.s2 10.0.0.3 s3 172.31.1.3 vlan1.s3 10.0.0.4 s4 172.31.1.4 vlan1.s4 172.31.1.9 d1 eth1.d1 172.31.1.10 d2 eth1.d2 172.31.1.11 d3 eth1.d3 172.31.1.12 d4 eth1.d4 172.31.1.5 r1 eth1.r1 172.31.1.6 r2 eth1.r2 172.31.1.7 r3 eth1.r3 172.31.1.8 r4 eth1.r4 10.0.0.1 s1 172.31.1.1 Vlan1.s1 SCRIPT grep "Created by netlab" /etc/hosts || uniq /tmp/hosts >>/etc/hosts # # Configure system defaults on Ubuntu # hostnamectl set-hostname s3 sysctl -w net.ipv4.ip_forward=1 sysctl -w net.ipv6.conf.all.forwarding=1 APT_INSTALL= # if which curl; then echo "Package curl already installed" else APT_INSTALL="$APT_INSTALL curl" fi # if which gpg; then echo "Package gnupg already installed" else APT_INSTALL="$APT_INSTALL gnupg" fi # if which bridge; then echo "Package iproute2 already installed" else APT_INSTALL="$APT_INSTALL iproute2" fi # # APT_INSTALL always starts with a blank, so we can't just check if it's empty # The following hack turns a string that contains only whitespaces into # an empty string and removes leading whitespaces # APT_INSTALL=`echo $APT_INSTALL` if [ -n "$APT_INSTALL" ]; then echo "Installing packages $APT_INSTALL" apt-get update -qq && apt-get install -qq $APT_INSTALL fi # # Install FRR on a Ubuntu VM if needed # if which /usr/lib/frr/frrinit.sh; then echo "FRR already installed, skipping installation" else curl -s https://deb.frrouting.org/frr/keys.asc >/etc/apt/trusted.gpg.d/frr.asc FRRVER="frr-stable" echo deb https://deb.frrouting.org/frr $(lsb_release -s -c) $FRRVER > /etc/apt/sources.list.d/frr.list apt-get update -qq && apt-get install -qq frr frr-pythontools bridge-utils ethtool fi # # Enable FRR modules (if not using containerlab bind-mounted /etc/frr/daemons) # # # Enable FRR daemons # /usr/lib/frr/frrinit.sh restart # # Create loopbacks, stub and lag/bond devices # if [ ! -e /sys/class/net/lo ]; then if [ ! -e /sys/devices/virtual/net/lo ]; then ip link add lo type dummy ip link set dev lo up fi fi # Disable IPv6 (for IPv4-only interfaces) or SLAAC (if the device is a router) # sysctl -qw net.ipv6.conf.eth1.disable_ipv6=1 ip link set dev eth1 mtu 1500 sysctl -qw net.ipv6.conf.eth2.disable_ipv6=1 ip link set dev eth2 mtu 1500 sysctl -qw net.ipv6.conf.eth3.disable_ipv6=1 ip link set dev eth3 mtu 1500 # # Add vtysh.conf file echo "service integrated-vtysh-config" >/etc/frr/vtysh.conf # # Rest of initial configuration done through VTYSH # cat >/tmp/config <<CONFIG hostname s3 ! frr defaults datacenter ! interface lo no shutdown ip address 10.0.0.3/32 ! interface eth1 no shutdown description s3 -> s1 ! no ip address ! interface eth2 no shutdown description [Access VLAN red] s3 -> r3 ! no ip address ! interface eth3 no shutdown description [Access VLAN vlan_1] s3 -> d3 ! no ip address ! interface eth1.700 no shutdown description [SubIf VLAN red] s3 -> s1 ! no ip address ! interface vlan1 no shutdown description VLAN vlan_1 (1) -> [s1,d1,s2,s4,d2...] ip address 172.31.1.3/24 ! interface vlan700 no shutdown description VLAN red (700) -> [s4,s1,r1,s2,r2...] ! no ip address ! do write CONFIG vtysh -f /tmp/config exit 0 ok: [s1] => msg: |- initial configuration for s1 ========================================= hostname s1 ! no ip domain lookup ! lldp run ! ip host d1 172.31.1.9 ip host d2 172.31.1.10 ip host d3 172.31.1.11 ip host d4 172.31.1.12 ip host r1 172.31.1.5 ip host r2 172.31.1.6 ip host r3 172.31.1.7 ip host r4 172.31.1.8 ip host s2 10.0.0.2 172.31.1.2 ip host s3 10.0.0.3 172.31.1.3 ip host s4 10.0.0.4 172.31.1.4 ! ip routing ! vlan 700 name red ! vlan 1 name vlan_1 ! ! ! interface Loopback0 ip address 10.0.0.1 255.255.255.255 ! interface GigabitEthernet0/0 no lldp transmit no lldp receive ! interface GigabitEthernet0/1 no switchport description s1 -> s2 no shutdown ! interface GigabitEthernet0/2 no switchport description s1 -> s3 no shutdown ! interface GigabitEthernet0/3 no switchport description s1 -> s4 no shutdown ! interface GigabitEthernet1/0 no switchport description [Access VLAN red] s1 -> r1 no shutdown ! interface GigabitEthernet1/1 no switchport description [Access VLAN vlan_1] s1 -> d1 no shutdown ! interface Vlan1 description VLAN vlan_1 (1) -> [s3,d1,s2,s4,d2...] ip address 172.31.1.1 255.255.255.0 mac-address 4001.cafe.0100 no shutdown ! interface Vlan700 description VLAN red (700) -> [s4,r1,s2,s3,r2...] mac-address 4001.cafe.0101 no shutdown ! ! line vty 0 4 exec-timeout 0 0 ! no banner exec no banner login no banner incoming TASK [Find configuration deployment deploy_script for initial] ***************** ok: [s2] ok: [s4] ok: [s3] ok: [d1] ok: [d4] ok: [d2] ok: [r1] ok: [d3] ok: [r2] ok: [r4] ok: [r3] ok: [s1] TASK [Deploy initial configuration] ******************************************** included: /home/pipi/net101/tools/netsim/ansible/tasks/deploy-config/frr.yml for s2, s3, s4 included: /home/pipi/net101/tools/netsim/ansible/tasks/deploy-config/linux-clab.yml for d1, d2, d3, d4, r1, r2, r3, r4 included: /home/pipi/net101/tools/netsim/ansible/tasks/deploy-config/ios.yml for s1 TASK [template] **************************************************************** changed: [s3] changed: [s2] changed: [s4] TASK [set_fact] **************************************************************** ok: [s2] ok: [s3] ok: [s4] TASK [run /tmp/config.sh to deploy initial config from /home/pipi/net101/tools/netsim/ansible/templates/initial/frr.j2] *** changed: [s4] changed: [s2] changed: [s3] TASK [run vtysh to import initial config from /home/pipi/net101/tools/netsim/ansible/templates/initial/frr.j2] *** skipping: [s2] skipping: [s3] skipping: [s4] TASK [Define script filename and determine whether to execute in netns] ******** ok: [d1] ok: [d2] ok: [d3] ok: [d4] ok: [r1] ok: [r2] ok: [r3] ok: [r4] TASK [Create a temporary file for the rendered script] ************************* changed: [r2 -> localhost] changed: [r4 -> localhost] changed: [d3 -> localhost] changed: [r3 -> localhost] changed: [d1 -> localhost] changed: [d2 -> localhost] changed: [d4 -> localhost] changed: [r1 -> localhost] TASK [Create container setup script from /home/pipi/net101/tools/netsim/ansible/templates/initial/linux-clab.j2] *** changed: [d2 -> localhost] changed: [d1 -> localhost] changed: [r4 -> localhost] changed: [d4 -> localhost] changed: [r2 -> localhost] changed: [d3 -> localhost] changed: [r1 -> localhost] changed: [r3 -> localhost] TASK [Copy script into running container at /tmp/config-d1_initial.sh] ********* skipping: [d1] skipping: [d2] skipping: [d3] skipping: [d4] skipping: [r1] skipping: [r2] skipping: [r3] skipping: [r4] TASK [Execute /tmp/config-d1_initial.sh to deploy initial config based on /home/pipi/net101/tools/netsim/ansible/templates/initial/linux-clab.j2] *** skipping: [d1] skipping: [d2] skipping: [d3] skipping: [d4] skipping: [r1] skipping: [r2] skipping: [r3] skipping: [r4] TASK [Container configuration for initial based on /home/pipi/net101/tools/netsim/ansible/templates/initial/linux-clab.j2 executed in netns] *** changed: [d2 -> localhost] changed: [d1 -> localhost] changed: [d3 -> localhost] changed: [r2 -> localhost] changed: [r4 -> localhost] changed: [r1 -> localhost] changed: [d4 -> localhost] changed: [r3 -> localhost] TASK [Remove temporary file /tmp/d1_initial-e2xr0t_u.sh] *********************** changed: [d4 -> localhost] changed: [d1 -> localhost] changed: [r4 -> localhost] changed: [r3 -> localhost] changed: [r2 -> localhost] changed: [d3 -> localhost] changed: [d2 -> localhost] changed: [r1 -> localhost] TASK [ios_config: deploying initial from /home/pipi/net101/tools/netsim/ansible/templates/initial/ios.j2] *** changed: [s1] PLAY [Deploy module-specific configurations] *********************************** TASK [Set variables that cannot be set with VARS] ****************************** ok: [s2] ok: [s3] ok: [s4] ok: [s1] TASK [Deploy individual configuration modules] ********************************* included: /home/pipi/net101/tools/netsim/ansible/tasks/deploy-module.yml for s1, s2, s3, s4 => (item=vlan) TASK [Figure out whether to deploy the module vlan on current device] ********** ok: [s2] ok: [s3] ok: [s4] ok: [s1] TASK [Find configuration template for vlan] ************************************ ok: [s2] ok: [s3] ok: [s4] ok: [s1] TASK [fail] ******************************************************************** skipping: [s1] skipping: [s2] skipping: [s3] skipping: [s4] TASK [Print deployed configuration when running in verbose mode] *************** ok: [s2] => msg: |- vlan configuration for s2 ========================================= #!/bin/bash # set -e # Exit immediately when any command fails # if [ ! -e /sys/devices/virtual/net/eth1.700 ]; then ip link add link eth1 name eth1.700 type vlan id 700 ip link set dev eth1.700 up fi if [ ! -e /sys/devices/virtual/net/eth1.1 ]; then ip link add link eth1 name eth1.1 type vlan id 1 ip link set dev eth1.1 up fi if [ ! -e /sys/devices/virtual/net/vlan700 ]; then brctl addbr vlan700 ip link set dev vlan700 address 52:dc:ca:fd:02:00 ip addr flush dev vlan700 fi if [ ! -e /sys/devices/virtual/net/vlan1 ]; then brctl addbr vlan1 ip link set dev vlan1 address 52:dc:ca:fd:02:01 ip link set dev vlan1 mtu 1500 ip addr flush dev vlan1 ip addr add 172.31.1.2/24 dev vlan1 fi brctl addif vlan700 eth2 brctl addif vlan1 eth3 brctl addif vlan700 eth1.700 brctl addif vlan1 eth1.1 ip link set dev vlan700 up ip link set dev vlan1 up exit 0 ok: [s3] => msg: |- vlan configuration for s3 ========================================= #!/bin/bash # set -e # Exit immediately when any command fails # if [ ! -e /sys/devices/virtual/net/eth1.700 ]; then ip link add link eth1 name eth1.700 type vlan id 700 ip link set dev eth1.700 up fi if [ ! -e /sys/devices/virtual/net/vlan1 ]; then brctl addbr vlan1 ip link set dev vlan1 address 52:dc:ca:fd:03:00 ip link set dev vlan1 mtu 1500 ip addr flush dev vlan1 ip addr add 172.31.1.3/24 dev vlan1 fi if [ ! -e /sys/devices/virtual/net/vlan700 ]; then brctl addbr vlan700 ip link set dev vlan700 address 52:dc:ca:fd:03:01 ip addr flush dev vlan700 fi brctl addif vlan1 eth1 brctl addif vlan700 eth2 brctl addif vlan1 eth3 brctl addif vlan700 eth1.700 ip link set dev vlan1 up ip link set dev vlan700 up exit 0 ok: [s1] => msg: |- vlan configuration for s1 ========================================= vlan 700 name red ! vlan 1 name vlan_1 ! ! interface GigabitEthernet0/1 switchport switchport trunk encapsulation dot1q switchport mode trunk switchport trunk allowed vlan 1,700 switchport trunk native vlan 1002 ! interface GigabitEthernet0/2 switchport switchport trunk encapsulation dot1q switchport mode trunk switchport trunk allowed vlan 1,700 switchport trunk native vlan 1 ! interface GigabitEthernet0/3 switchport switchport trunk encapsulation dot1q switchport mode trunk switchport trunk allowed vlan 1,700 switchport trunk native vlan 700 ! interface GigabitEthernet1/0 switchport switchport access vlan 700 ! interface GigabitEthernet1/1 switchport switchport access vlan 1 ok: [s4] => msg: |- vlan configuration for s4 ========================================= #!/bin/bash # set -e # Exit immediately when any command fails # if [ ! -e /sys/devices/virtual/net/eth1.1 ]; then ip link add link eth1 name eth1.1 type vlan id 1 ip link set dev eth1.1 up fi if [ ! -e /sys/devices/virtual/net/vlan700 ]; then brctl addbr vlan700 ip link set dev vlan700 address 52:dc:ca:fd:04:00 ip addr flush dev vlan700 fi if [ ! -e /sys/devices/virtual/net/vlan1 ]; then brctl addbr vlan1 ip link set dev vlan1 address 52:dc:ca:fd:04:01 ip link set dev vlan1 mtu 1500 ip addr flush dev vlan1 ip addr add 172.31.1.4/24 dev vlan1 fi brctl addif vlan700 eth1 brctl addif vlan700 eth2 brctl addif vlan1 eth3 brctl addif vlan1 eth1.1 ip link set dev vlan700 up ip link set dev vlan1 up exit 0 TASK [Find configuration deployment deploy_script for vlan] ******************** ok: [s2] ok: [s3] ok: [s4] ok: [s1] TASK [Deploy vlan configuration] *********************************************** included: /home/pipi/net101/tools/netsim/ansible/tasks/deploy-config/ios.yml for s1 included: /home/pipi/net101/tools/netsim/ansible/tasks/deploy-config/frr.yml for s2, s3, s4 TASK [ios_config: deploying vlan from /home/pipi/net101/tools/netsim/ansible/templates/vlan/iosvl2.j2] *** changed: [s1] TASK [template] **************************************************************** changed: [s2] changed: [s3] changed: [s4] TASK [set_fact] **************************************************************** ok: [s2] ok: [s3] ok: [s4] TASK [run /tmp/config.sh to deploy vlan config from /home/pipi/net101/tools/netsim/ansible/templates/vlan/frr.j2] *** changed: [s2] changed: [s3] changed: [s4] TASK [run vtysh to import vlan config from /home/pipi/net101/tools/netsim/ansible/templates/vlan/frr.j2] *** skipping: [s2] skipping: [s3] skipping: [s4] PLAY [Deploy custom deployment templates] ************************************** skipping: no hosts matched PLAY RECAP ********************************************************************* d1 : ok=16 changed=4 unreachable=0 failed=0 skipped=8 rescued=0 ignored=0 d2 : ok=16 changed=4 unreachable=0 failed=0 skipped=8 rescued=0 ignored=0 d3 : ok=16 changed=4 unreachable=0 failed=0 skipped=8 rescued=0 ignored=0 d4 : ok=16 changed=4 unreachable=0 failed=0 skipped=8 rescued=0 ignored=0 r1 : ok=16 changed=4 unreachable=0 failed=0 skipped=8 rescued=0 ignored=0 r2 : ok=16 changed=4 unreachable=0 failed=0 skipped=8 rescued=0 ignored=0 r3 : ok=16 changed=4 unreachable=0 failed=0 skipped=8 rescued=0 ignored=0 r4 : ok=16 changed=4 unreachable=0 failed=0 skipped=8 rescued=0 ignored=0 s1 : ok=24 changed=3 unreachable=0 failed=0 skipped=4 rescued=0 ignored=0 s2 : ok=24 changed=4 unreachable=0 failed=0 skipped=9 rescued=0 ignored=0 s3 : ok=24 changed=4 unreachable=0 failed=0 skipped=9 rescued=0 ignored=0 s4 : ok=24 changed=4 unreachable=0 failed=0 skipped=9 rescued=0 ignored=0 The topology tests whether the device deals correctly with VLAN 1 in a vlan.trunk: * As a native VLAN * As a regular (tagged) VLAN * In a trunk where another VLAN is a native VLAN All r* hosts should be able to ping each other and all d* hosts should be able to ping each other. Please note it might take a while for the lab to work due to STP learning phase