Home » Network Automation: Ansible, Python Netmiko, NAPALM, Terraform, CI/CD และ Infrastructure as Code
Network Automation: Ansible, Python Netmiko, NAPALM, Terraform, CI/CD และ Infrastructure as Code
Network Automation: Ansible, Python Netmiko, NAPALM, Terraform, CI/CD และ Infrastructure as Code
Network Automation เปลี่ยนการจัดการ network จาก manual CLI เป็น automated workflows Ansible ใช้ YAML playbooks สำหรับ configuration management, Python Netmiko เป็น SSH library สำหรับ network devices, NAPALM ให้ vendor-neutral interface, Terraform จัดการ infrastructure as code, CI/CD ให้ automated testing และ deployment และ Infrastructure as Code ทำให้ network config เป็น version-controlled
Network engineers ใช้เวลา 70-80% กับ repetitive tasks: configure VLANs, update ACLs, change passwords, deploy configs ข้าม 100+ devices → manual = slow, error-prone, inconsistent Gartner ประเมินว่า 70% ของ network outages เกิดจาก human error ในการ configure automation ลดข้อผิดพลาด 90%+, เร็วขึ้น 10-100x และทำให้ network ทำงานเหมือน software development (NetDevOps)
Automation Tools Comparison
| Tool |
Type |
Language |
Best For |
| Ansible |
Configuration Management |
YAML (playbooks) |
Multi-vendor config push, compliance, provisioning |
| Python + Netmiko |
SSH Automation Library |
Python |
Custom scripts, show commands, parsing output |
| NAPALM |
Vendor-Neutral Library |
Python |
Get/set config, compare, rollback — multi-vendor |
| Terraform |
Infrastructure as Code |
HCL |
Cloud networking (VPC, firewall rules, load balancers) |
| Nornir |
Automation Framework |
Python |
Complex workflows, parallel execution, inventory management |
| Salt |
Event-Driven Automation |
YAML/Python |
Real-time event response, large-scale config management |
Ansible for Network
| Feature |
รายละเอียด |
| Agentless |
ไม่ต้องติดตั้ง agent บน network devices — ใช้ SSH หรือ NETCONF |
| Playbooks |
YAML files: define tasks (config VLAN, set interface, update ACL) in declarative format |
| Modules |
ios_config, nxos_vlan, junos_command, eos_config — vendor-specific modules |
| Inventory |
Define devices: hostname, IP, platform, credentials — group by site/role/vendor |
| Idempotent |
Run playbook multiple times → same result (ไม่ duplicate config) |
| Roles |
Reusable collections of tasks, templates, variables — organize complex automation |
| AWX/Tower |
Web UI, RBAC, scheduling, audit trail — enterprise Ansible management |
Python Netmiko
| Feature |
รายละเอียด |
| คืออะไร |
Python library for SSH connections to network devices — simplify Paramiko for networking |
| Supports |
Cisco IOS/NX-OS/ASA, Arista EOS, Juniper JunOS, HP, Fortinet, Palo Alto, 50+ platforms |
| send_command() |
Send show commands → return output as string → parse with TextFSM/Genie |
| send_config_set() |
Send config commands → enter config mode → push commands → exit |
| TextFSM |
Parse CLI output into structured data (JSON/dict) — NTC Templates library |
| Use Cases |
Backup configs, audit compliance, mass config changes, gather inventory |
NAPALM
| Feature |
รายละเอียด |
| คืออะไร |
Network Automation and Programmability Abstraction Layer with Multivendor support |
| Vendor-Neutral |
Same Python code works on Cisco, Juniper, Arista, etc. — abstracted interface |
| get_facts() |
Return device info: hostname, vendor, model, serial, uptime, interfaces |
| get_config() |
Return running/startup/candidate config |
| load_merge_candidate() |
Load new config → merge with existing (additive) |
| compare_config() |
Show diff between candidate and running config → review before applying |
| commit_config() / discard_config() |
Apply or discard changes → safe config deployment with rollback capability |
Terraform for Network
| Feature |
รายละเอียด |
| คืออะไร |
Infrastructure as Code tool — declare desired state → Terraform creates/modifies resources |
| Providers |
AWS (VPC, SG, ALB), Azure (VNet, NSG), GCP, Palo Alto, Fortinet, Cisco ACI |
| Plan |
terraform plan → show what will change before applying → safe review |
| Apply |
terraform apply → create/modify/destroy resources to match desired state |
| State |
State file tracks current infrastructure → knows what exists and what needs to change |
| Modules |
Reusable infrastructure components (VPC module, firewall module) → DRY principle |
| Best For |
Cloud networking: VPCs, subnets, security groups, load balancers, DNS, CDN |
CI/CD for Network (NetDevOps)
| Stage |
Action |
Tools |
| Source Control |
Store configs, playbooks, templates in Git |
Git, GitHub, GitLab |
| Lint/Validate |
Check syntax, validate YAML, check config standards |
yamllint, ansible-lint, Batfish |
| Test |
Test config in lab/simulation before production |
Batfish (offline verification), GNS3, CML, containerlab |
| Build |
Generate device-specific configs from templates + variables |
Jinja2 templates + Ansible/Python |
| Deploy |
Push configs to devices (staged rollout, canary deployment) |
Ansible, NAPALM, Nornir |
| Verify |
Post-deployment checks: ping tests, route checks, service validation |
Ansible assert, pyATS, custom scripts |
| Monitor |
Watch for issues after deployment → auto-rollback if needed |
Prometheus, ThousandEyes, SNMP alerts |
ทิ้งท้าย: Automate or Be Automated
Network Automation Ansible: agentless, YAML playbooks, idempotent, multi-vendor modules — most popular for network config Netmiko: Python SSH library, send_command/send_config_set, TextFSM parsing — custom scripts NAPALM: vendor-neutral abstraction, get/set config, compare_config, commit/rollback — safe deployment Terraform: IaC for cloud networking (VPC, SG, LB), plan before apply, state management CI/CD: Git → lint → test (Batfish) → build (Jinja2) → deploy (Ansible) → verify → monitor Key: 70% of outages = human error — automation reduces errors 90%+, speeds up 10-100x, enables NetDevOps
อ่านเพิ่มเติมเกี่ยวกับ Network Programmability YANG NETCONF RESTCONF และ Software-Defined Networking SDN Controller OpenFlow ที่ siamlancard.com หรือจาก icafeforex.com และ siam2r.com