Automatic white Box switch network construction method for beginners ~ZTP x Ansible~

Introduction

In the 2nd to 4th articles that covered Open Networking, we introduced “Zero Touch Provisioning (ZTP)” and “Ansible” respectively. In this article, we will introduce a more efficient network construction method that can be implemented by combining the two.

There are other articles related to Open Networking, so please click here for a list of articles to find the article you are interested in.

About ZTP and Ansible

What you can do with ZTP

To briefly review ZTP, simply by connecting to the network where you want to introduce a device such as a white Box switch and turning on the power, settings will be automatically made and it will be ready for use.
If you draw a diagram, the flow will be as follows, and you can easily build it if you prepare DHCP Sever and Web Server.

① DHCP request starts when the white Box switch is activated
② DHCP Server replies Ack to DHCP Request from white Box switch
At this time, not only the IP address but also the storage location of the NOS image file, License, and Config file are notified.
③ The white Box switch accesses the Web server based on the information notified from the DHCP server
④ Download the NOS image file, License, and Config file from the Web Server, apply the downloaded files to the white Box switch, and complete the setting work.

Configuration example of ZTP

For more information on ZTPArticle 4There is a detailed explanation in, so please take a look if you like

ZTP Advantages/Disadvantages

The advantages/disadvantages of using ZTP alone are as follows.

[merit]
・Because the setting is simple, it is not difficult to build a ZTP environment

[Demerit]
・It is necessary to create Config for each white Box switch in advance
・If there is no mechanism to automatically correct any changes to the initial settings, it is necessary to manually correct all Configs.

The construction of the ZTP environment itself is not difficult, but it is necessary to prepare Config for each white Box switch, and the larger the number, the more time it takes to prepare manually.

What you can do with ZTP x Ansible

Next, I will introduce ZTP x Ansible.
The basic flow is the same as ZTP alone, but Config can be created with Ansible.

① Adapt Config of each white Box switch with ZTP (Config is created with Ansible)
② When changing settings, edit/execute Playbook on Ansible host to change settings in real time (effective when inputting the same settings to many switches)
③ Using Ansible host, it is possible to back up the Config of each device on a regular basis
* A playbook is a file that describes the process to be executed.

Advantages/disadvantages of ZTP x Ansible

The advantages/disadvantages of combining ZTP and Ansible are as follows.


[merit]
・You can create each Config with Ansible, and you can easily change the initial settings after that.
・After starting ZTP, Ansible can be used to change settings for white Box switches in real time.
・Using Ansible, regular backup of Config is possible

[Demerit]
・Ansible learning cost is high

It is possible to greatly reduce the Config creation work that was required when using ZTP alone. Also, once you create an Ansible playbook, you can easily change the settings and expand the equipment afterwards. In addition, it is also possible to take regular backups of the configs of each white Box switch, making it possible to further automate operations.

*How to create a Config using Ansible is introduced in detail in the 3rd article, so please take a look.

How to get a backup using Ansible

Next, I will introduce how to get an Ansible backup, which was described in the benefits of ZTP x Ansible.

By regularly backing up the white Box switch, you can always get the latest Config. As a result, even if the white Box switch fails, ZTP can quickly apply the latest Config to the replacement device, making it possible to respond more quickly.

environment
・Server
-Ubuntu 16.04
・White Box switch
-Edgecore: AS7726-32X
・NOS
-OcNOS 1.3.9

Backup acquisition configuration diagram

Ansible directory structure


├── hosts # inventory file

├── set_crontab.yml # Playbook file to execute

└── backup.yml # Playbook file executed by cron job

Set the playbook (set_crontab.yml) as below and create a script that executes the cron job (backup.yml) every minute.

set_crontab.yml
---
- hosts: localhost
  gather_facts: false
  tasks:
    - name: set crontab
      cron:
        name: backup_config
        job: "/usr/bin/ansible-playbook -i ~/Ansible/ocnos-bgp-ansible/hosts  ~/Ansible/ocnos-bgp-ansible/backup.yml


The playbook executed by the cron job is below.

backup.yml

---
- name: Buck up running-config
  gather_facts: no
  hosts: OCNOS
  vars:
    now_date: "{{ lookup('pipe','date +%Y%m%d%H%M') }}"
  tasks:
    - ocnos_config:
          exec_cmds:
                - 'copy running-config scp scp://tecstar:tecstar@192.168.0.80/tmp/configs/{{ inventory_hostname }}_bk.conf.{{ now_date }} vrf management'

Run playbooks with Ansible

By executing the playbook (set_crontab.yml) from the command below, the regular backup setting is completed.

ansible-playbook set_crontab.yml

After running the playbook, make sure your crontabs are set correctly.

コマンド実行
#Ansible: backup_config
* * * * * /usr/bin/ansible-playbook -i ~/Ansible/ocnos-bgp-ansible/hosts  ~/Ansible/ocnos-bgp-ansible/backup.yml  ---->正常に設定されていることが確認できる-->tecstar@tecstar:~$ crontab -l    ----->コマンド実行 #Ansible: backup_config * * * * * /usr/bin/ansible-playbook -i ~/Ansible/ocnos-bgp-ansible/hosts ~/Ansible/ocnos-bgp-ansible/backup.yml  ---->正常に設定されていることが確認できる

Also, as shown below, Config is actually acquired every minute, and it can be confirmed that it is operating normally.
(This time, the file name has a time stamp, and the backup was taken at 16:53, 16:54, 16:55, and 16:56)

tecstar@tecstar:/tmp/configs$ ls AS7726-A_bk.conf.202107191653 AS7726-A_bk.conf.202107191654 AS7726-A_bk.conf.202107191655 AS7726-A_bk.conf.202107191656



That was the introduction of the automation solution using ZTP and Ansible.
Next time, we plan to introduce monitoring/visualization methods using OSS tools.

At the end

Macnica offers a service that provides a remote environment where you can actually experience open networking and conduct testing and verification.
This service allows us to verify the operability of the network OS and perform tests that combine network OSs, white Box switches, and optical transceivers from various manufacturers.

Remote verification service image diagram

This is a service that allows you to easily verify open networking, and use of the basic configuration is free of charge.
For information about available network OS and white Box switches, specific use cases, and how to apply, please refer to the downloadable materials. The materials can be downloaded from the URL provided in the notification email after answering the questionnaire at the "Macnica Network OS Remote Verification Service" below.

These people are using the remote verification service.

Here are some testimonials from people who have actually used the service.

 Furukawa Network Solution Co., Ltd.
“Recently, the number of remote service environments is increasing, but I was impressed with the ease of access to the evaluation equipment.
The materials you provided were easy to understand, and we were able to proceed smoothly with the intended verification. ”


Related information

Click here for list of materials

Document list

In addition to introducing products handled by Macnica,
We publish materials related to open networking, such as BGP cross network automatic construction files and network operation test evaluation reports.

Click here for details

Product Page Top

Edgecore Networks

We continue to be a pioneer in open networking by developing and selling products related to OpenNetworking/white Box switches.

DELTA ELECTRONICS

We have many achievements in supporting the business of major OEM customers in Japan and overseas, and provide high-quality/high-reliability network products. .

CGS Tower Networks

We provide a network packet broker (NPB) that utilizes state-of-the-art general-purpose hardware.

Inquiry

If you have any questions regarding this article, please contact us below.

Macnica
In charge of OpenNetwork

Contact us by phone:
045-470-9831