Network automation : Ansible et Python
L'automatisation réseau (network automation) est obligatoire en 2026 pour gérer efficacement 50+ équipements. Ansible, Python (NAPALM, Netmiko, PyEZ), Terraform, NETCONF/YANG sont les standards. Ce guide couvre les fondations : outils, bonnes pratiques, exemples réels, CI/CD réseau, GitOps.
Pourquoi automatiser
- Réduire erreurs humaines (typos CLI)
- Cohérence config (pas de drift entre switchs)
- Rapidité déploiement (100 VLAN push en 5 min vs 4 heures)
- Traçabilité (git history)
- Rollback rapide
- Documentation vivante (config = code)
Outils principaux
Ansible
- Agent-less (SSH/NETCONF/HTTPS)
- Modules par vendor : cisco.ios, cisco.nxos, arista.eos, juniper.junos, fortinet.fortios
- Simplicité YAML, large communauté
- Idempotent : run multiple times = même résultat
- Inventaire : static ou dynamique (Nautobot, NetBox)
Python + bibliothèques
- Netmiko : SSH multi-vendor basique
- NAPALM : API unifiée (get_facts, get_interfaces, config merge)
- PyEZ (Juniper) : NETCONF/YANG native
- Nornir : framework Python pour orchestration
- Requests : REST API
Terraform
- Infra-as-code déclaratif
- Providers : VMware NSX, AWS, Azure, Cisco ACI, FortiGate, Palo Alto Panorama
- State file : reflète état déployé
- Idéal cloud infra + équipements à API REST
NETCONF/YANG
- Standard IETF (RFC 6241)
- Config/data modeling YAML + XML
- Support : Cisco IOS-XE/NX-OS, Juniper Junos, Arista EOS
- Préféré à CLI parsing pour fiabilité
Source of Truth (SoT)
Toute automation commence par une SoT :
- Nautobot / NetBox (open source) : IPAM + DCIM + automation
- Infoblox DDI : commercial, leader entreprise
- Excel (pour débuter) — pas scalable
- YAML files in git (simple, GitOps-friendly)
- DNAC inventory (Cisco)
Exemple Ansible : push VLAN sur 10 switchs Cisco
- # inventory.yml : tous les switchs group tagged 'access'
- # playbook-vlans.yml
- - hosts: access
- tasks:
- - name: Create VLAN 10
- cisco.ios.ios_vlan:
- vlan_id: 10
- name: DATA
- state: present
Exemple Python NAPALM (get facts)
- from napalm import get_network_driver
- driver = get_network_driver('ios')
- dev = driver('10.0.0.1', 'admin', 'pass')
- dev.open()
- print(dev.get_facts())
- print(dev.get_interfaces_ip())
- dev.close()
CI/CD réseau (GitOps)
Workflow type
- 1. Engineer modifie YAML dans Git repo
- 2. Pull Request + review par pair
- 3. CI pipeline : validation syntaxe, dry-run Ansible/Batfish
- 4. Merge → déploiement automatique (ou manuel approval)
- 5. Test post-deploy (ping, BGP state)
- 6. Rollback automatique si test fail
Tools CI/CD
- GitLab CI, GitHub Actions, Jenkins
- Batfish : validation config avant deploy (dry-run)
- SuzieQ : observabilité réseau pour CI tests
- pytest + Nornir : tests programmables
Orchestration vendors
- Cisco DNA Center : orchestration SD-Access, Assurance
- Juniper Apstra : intent-based multi-vendor (voir article)
- FortiManager : templates + policies orchestration
- Aruba Central (SaaS) : provisioning sur cloud
- NetBrain : Automation + Network Assessment
AIOps (émerging)
- Juniper Mist Marvis : chatbot IA pour troubleshooting
- Cisco ThousandEyes AI : anomaly detection
- HPE AIOps : ML models pour prédiction saturation
Pyramide de maturité
- Niveau 1 : scripts manuels ad-hoc (Python one-shots)
- Niveau 2 : playbooks Ansible + SoT static (YAML/Excel)
- Niveau 3 : CI/CD + SoT dynamique (Nautobot/NetBox)
- Niveau 4 : intent-based (Apstra, DNA Center)
- Niveau 5 : self-healing + AI (Marvis, DNA Center AI)
Commander chez OPTINOC
Formation automation réseau (Ansible + Python + NetBox/Nautobot) pour équipes clients. Déploiement CI/CD réseau. Intégration Juniper Apstra / Cisco DNA Center. Devis sous 48h.
