|

[Aruba DevNet Lecture 3] Automating Simultaneous Switch Configuration: Windows Python vs. Linux Ansible

⏱️ Estimated reading time: Approx. 6 minutes (6 min read)

Lecture 2In , we experienced automation in 'reading' data through the New Central API.
But what makes an engineer's heart beat is 'the ability to freely adjust the equipment settings.'.

Today, we'll learn how to implement automation in two environments (Windows and Linux) using Aruba CX switches.

CX switches support REST APIs, allowing for a variety of automation and programming possibilities.

[Aruba DevNet 3강] 스위치 동시 설정 자동화: Windows 파이썬 vs Linux 앤서블(Ansible) - image 3

1. Which Automation Tool Should I Use? (Netmiko vs. Ansible)

  • Windows environment: If you find installing Linux burdensome? The most popular Netmiko The library is the answer.
    As long as you have Python, you can SSH into the switch from anywhere and push the settings.
  • Linux environment: What if you want full-fledged IaC (Infrastructure as Code)? AnsibleThis is the standard.
    Manage hundreds of switches simultaneously with just a YAML file, without any separate coding.

2. [Windows] Getting Started with Python Netmiko

If you are a Windows user, you only need to add one more library to the environment you set up last time.

PowerShell
python -m pip install netmiko

[cx_config.py]

Python
from netmiko import ConnectHandler

# switch connection information
device = {
    ''device_type'': ''aruba_os_cx'',
    ''host'': '192.168.1.100',
    ''username'': ''admin'',
    ''password'': ''Password!'',
}

# Apply setting command axis
commands = [
    ''vlan 10'',
    ''name Guest_VLAN'',
    ''interface 1/1/1'',
    ''vlan access 10''
]

with ConnectHandler(**device) as net_connect:
    print(""🚀 Setting up the switch..."")
    output = net_connect.send_config_set(commands)
    print(output)

3. [Linux] Implementing Powerful Batch Control with Ansible

If you have a Linux (Ubuntu/WSL) environment, you can use the official service provided by Aruba. Ansible CollectionIt is most powerful to use .

[installation]

Bash
Installing the # Ensemble and Aruba Collection
sudo apt update && sudo apt install ansible -y
ansible-galaxy collection install arubanetworks.aos_cx

[inventory.ini] – List of managed switches

INI
[cx_switches]
sw-leaf-01 ansbile_host=192.168.1.101
sw-leaf-02 ansbile_host=192.168.1.102

[cx_switches:vars]
ansible_user=admin
ansible_password=Password!
ansible_network_os=arubanetworks.aos_cx.aos_cx

[vlan_setup.yml] – A playbook that defines the actual “what to do”

YAML
---
- name: Bulk VLAN configuration on Aruba CX switches
  hosts: cx_switches
  gather_facts: no
  tasks:
    - name: Create and name VLAN 10
      arubanetworks.aos_cx.aos_cx_vlan:
        vlan_id: 10
        name: ""DevNet_VLAN""
        state: present

[execution]

Bash
ansible-playbook -i inventory.ini vlan_setup.yml

4. How to choose the right tool for your environment

“We can't say that "ensemble is always the best.".

  • One-time tasks or simple checks: On Windows NetmikoIt is efficient to quickly write scripts.
  • Regular operation and standardization: On the server AnsibleIt is advantageous for maintenance to build a configuration file (YAML) and manage the version (Git).

The key is to “reduce the time I spend typing by connecting to the console directly”, no matter what tool I use.


In conclusion

Today we have two wings: Windows and Linux.
Now your Aruba CX switches are ready to move seamlessly with a single line of code.

next semifinalsIn “Webhook and Slack Integration in Aruba Central,” we will create intelligent automation that allows the equipment to talk to me directly when a problem occurs!

Similar Posts

  • [ACSA Education #32] Layer 3 Fundamentals

    ⏱️ Estimated reading time: Approx. 7 minutes (7 min read) Having conducted about 30 training posts related to ACSA, I have covered content centered on Layer 2. Now, I would like to move up a step from Layer 2 and discuss Layer 3 content. We will examine Layer 3 topics such as IP packets, routing, and gateways. So, let's start by...

  • [Monitoring with Icinga Part 1] Basic Integration with Icinga 2 – SNMP & REST API

    ⏱️ Estimated Reading Time: Approx. 6 minutes (6 min read) 1. Introduction: Infrastructure Monitoring, Why Icinga 2? When operating enterprise networks and infrastructure, Zabbix is by far the most familiar open-source monitoring tool to engineers in Korea. Thanks to its intuitive web GUI, various default templates, and an all-in-one environment consisting of a single package, numerous enterprise…

  • [acp-dc training#10] vsx (2)

    ⏱️ Estimated reading time: Approx. 8 minutes (8 min read) In the previous post, we explored VSX, the virtualization technology of HPE Aruba Networking AOS-CX switches. We explained the components of VSX, the differences from VSF, and its advantages. Today, we would like to cover the practical aspects. We will examine how to actually utilize VSX to perform live software upgrades and look at technologies such as Split Brain… .

  • [ACSA Education #34] VRRP

    ⏱️ Estimated reading time: Approx. 10 minutes (10 min read) In the previous post, we looked at the Default Gateway. An endpoint can have only one Default Gateway. And it can be a single point of failure. Looking at the figure below, if Core-1 fails, PC-1 and others using Core-1 as the Default Gateway…

  • [APSC Training #4] Aruba Central Device Onboarding

    ⏱️ Estimated reading time: Approx. 7 minutes (7 min read) The first step in learning Aruba Central is onboarding devices to the cloud. There are four ways to add network devices to the cloud. Before starting the Aruba Activate Zero Touch Provisioning (ZTP) process, you must understand Aruba Activate, the core component of Aruba device provisioning… .

  • [ACSA Training #36] Routing Protocols

    ⏱️ Estimated reading time: Approx. 7 minutes (7 min read) Before learning about routing protocols, we need to understand an AS (Autonomous System). An Autonomous System can be described as a collection of routers under a management domain. In other words, an ISP (Internet Service Provider) owns its own internal network. And the ISP extends to the routers within that network…