Automation and Configuration Management
What this domain covers
Automation and configuration management tests your ability to change Junos devices safely and repeatably: the Junos commit model, Junos PyEZ, and configuration management tools such as Ansible and Salt.
Core rules and concepts
- The Junos commit model is the safety net. Configuration is built in a candidate config, validated with
commit check, and applied atomically.commit confirmed <minutes>auto-rolls back unless confirmed, androllback nrestores an earlier commit. - Junos PyEZ is the Python library for Junos.
Deviceopens a NETCONF session (TCP 830 by default). TheConfigutility handleslock(),load(),commit_check(),commit(),rollback()andunlock();mode='exclusive'takes an exclusive lock. - Tables and Views parse operational output into Python dictionaries, so you never regex
showtext. - Ansible uses the
juniper.devicecollection (junos_config,junos_command,junos_facts) overnetconfornetwork_cli. Modules should be idempotent: a second run reportschanged=false. - Salt runs Junos as a proxy minion; NAPALM gives a multi-vendor getter/setter abstraction.
Worked example
Goal: ensure ge-0/0/1 has description UPLINK-A. Read first with dev.rpc.get_config(filter_xml=...) and compare the description; if it already matches, exit without loading. If not, enter Config(dev, mode='exclusive'), load() a small XML snippet with merge semantics, run commit_check(), then commit(comment='...'). Idempotent, locked and validated - the three things a mark scheme looks for.
Traps
load mergevsload replacevsload overridevsload set: merge adds, replace swaps a hierarchy, override discards everything else.- Skipping
commit checkbeforecommit. - Forgetting that an exclusive lock blocks other users, and failing to
unlock()ordev.close(). - Screen-scraping CLI output instead of using NETCONF/XML.