Infrastructure Automation
Infrastructure Automation tests programmability and automation concepts: data formats, NETCONF, RESTCONF, YANG, Python, EEM, and controller or agent tooling. Questions ask you to interpret an API request, choose a data encoding, or explain why an automation task is not idempotent.
Data formats and APIs
JSON uses objects, arrays, strings, numbers, booleans, and null; it does not allow comments. XML is a case-sensitive tree. YAML is indentation-sensitive and common in Ansible. YANG defines a data model; it is not a wire format. RESTCONF uses HTTP methods GET, POST, PUT, PATCH, and DELETE over HTTPS, normally with JSON or XML. Status 200 is success, 201 is created, 204 is no content, 400 is bad request, 401 is unauthorized, and 404 is not found.
Model-driven configuration
NETCONF runs over SSH port 830 and uses XML RPC. It can target running, candidate, and startup datastores; edit-config changes configuration, get-config reads it, and commit applies a candidate. YANG modules define containers, lists, leaves, and leaf-lists. RESTCONF paths commonly begin /restconf/data/<module>:<container>.
Python, EEM, and tooling
Python requests sends HTTP; json.loads() converts a JSON string to a dictionary and json.dumps() does the reverse. Indentation defines blocks. EEM applets combine an event such as CLI, syslog, timer, or track with actions such as CLI commands or syslog messages. Ansible is agentless over SSH and uses YAML playbooks and an inventory; Puppet and Chef typically use agents. Idempotent automation converges to the same state when rerun.
Worked example
Read GigabitEthernet1 with RESTCONF: GET https://198.51.100.1/restconf/data/ietf-interfaces:interfaces/interface=GigabitEthernet1, with headers Accept: application/yang-data+json and basic authentication. A 200 response contains an ietf-interfaces:interface object; read its config leaves. A 404 usually means a wrong module or interface name; 401 means credentials. To change only the description, use PATCH; PUT replaces the target resource.
Traps
- Sending JSON to NETCONF; NETCONF expects XML.
- Treating YANG as an encoding.
- Omitting RESTCONF media-type headers.
- Assuming every automation tool needs an agent.
- Forgetting that EEM actions require a matching event.