0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

JN0-423 Study Guide: JNCIS-DevOps gNMI Telemetry, Ansible, JSNAPy, Commit Scripts and YANG with Hands-On Examples

0
Posted at

The JN0-423 exam is the written test for JNCIS-DevOps (Automation and DevOps, Specialist), the second level of the Juniper Automation and DevOps track. It checks that you understand how Junos devices are automated beyond basic PyEZ and NETCONF: gRPC and gNMI streaming telemetry, Ansible with Jinja2, Vault and JSNAPy, on-box commit, op, event and SNMP scripts, and YANG data models. It has 65 multiple-choice questions in 90 minutes, is based on Junos OS 24.4, and requires JNCIA-DevOps first. This JN0-423 study guide walks through each objective with configuration, CLI and runnable Python examples so you can test each idea yourself.

JN0-423 at a glance

Item Detail
Exam code JN0-423
Certification JNCIS-DevOps (Automation and DevOps, Specialist)
Prerequisite JNCIA-DevOps (JN0-224)
Questions 65 multiple choice
Duration 90 minutes
Software version Junos OS 24.4
Passing score Not published; pass/fail shown immediately after the exam
Price USD 300
Language English only
Delivery Pearson VUE
Validity 3 years
Recommended course Juniper Platform Automation and NetDevOps

The official JNCIS-DevOps certification overview has registration, practice exams and the objective list. The JN0-423 syllabus lays out the same five sections with every sub-topic in one table, which works well as a checklist.

How JN0-423 differs from JN0-224

If you passed JNCIA-DevOps, you already know PyEZ, NETCONF, XPath, the REST API and basic Python. JN0-423 moves up a level.

Topic JNCIA-DevOps (JN0-224) JNCIS-DevOps (JN0-423)
Transport NETCONF, REST API gRPC, gNMI, protobuf
Data XML, JSON, XPath YANG models, OpenConfig, sensor paths
Tooling PyEZ, Python Ansible, Jinja2, Vault, JSNAPy, gNMIc, TIG stack, Terraform
On-box Not covered in depth Commit, op, event and SNMP scripts
Architecture Junos automation stack MGD-based vs JSD-based (JET) automation

The five exam sections

Section What you need to know
Platform Automation Overview MGD-based automation, Terraform, Juniper Extension Toolkit (JET) and JSD-based automation
gRPC gRPC and gNMI for configuration and for telemetry: protobuf, OpenConfig, sensor paths, gNMIc, TIG stack
Ansible Supported files, playbooks, Vault, JSNAPy, Jinja2 templates
Junos Automation Scripts Commit, op, event and SNMP scripts
YANG Implementation concepts, OpenConfig, YANG syntax and data types

Juniper does not publish section weights. In practice, gRPC/telemetry and Ansible carry the most detail, so give them the most lab time.

1. Platform automation overview: MGD vs JSD

Junos has two automation planes, and the exam expects you to place each tool on the right one.

  • MGD-based: everything that goes through the management daemon, the same path as the CLI. NETCONF, the REST API, PyEZ, Ansible and on-box scripts all live here. A commit through MGD also runs your commit scripts.
  • JSD-based: the Juniper Extension Toolkit (JET) service daemon exposes gRPC APIs, including gNMI, for off-box programs written in any language that has a gRPC library.
  • Terraform: declarative, state-based configuration. You describe the desired configuration, terraform plan shows the difference, and terraform apply pushes it. Know that Terraform keeps a state file and works through a provider. Imperative tools such as a playbook simply run their tasks in order.

2. gRPC, gNMI and protobuf

gRPC runs over HTTP/2 and encodes messages with Protocol Buffers (protobuf). gNMI is the gRPC service for network management. It has four RPCs: Capabilities, Get, Set and Subscribe.

Enabling gRPC on Junos

set system services extension-service request-response grpc ssl port 32767
set system services extension-service request-response grpc ssl local-certificate grpc-cert
set system services extension-service request-response grpc ssl mutual-authentication client-certificate-request require-certificate

Labs sometimes run gRPC in clear text to skip certificates. Never do that in production, because credentials and configuration then cross the network unencrypted.

Protobuf wire format, decoded by hand

Exam questions on protobuf are conceptual: fields are numbered, the encoding is binary and compact, and you need the .proto schema to know field names. The sketch below decodes a message without the schema. You can see the field numbers and types, but not their names.

# Decode protobuf wire format by hand (no .proto file needed)
def read_varint(buf, i):
    shift = result = 0
    while True:
        b = buf[i]; i += 1
        result |= (b & 0x7F) << shift
        if not b & 0x80:
            return result, i
        shift += 7

def encode_varint(n):
    out = bytearray()
    while True:
        b = n & 0x7F; n >>= 7
        out.append(b | (0x80 if n else 0))
        if not n:
            return bytes(out)

def decode(buf):
    i, fields = 0, []
    while i < len(buf):
        key, i = read_varint(buf, i)
        field, wire = key >> 3, key & 7
        if wire == 0:                      # varint
            val, i = read_varint(buf, i)
        elif wire == 2:                    # length-delimited
            ln, i = read_varint(buf, i)
            val = buf[i:i + ln].decode(); i += ln
        else:
            raise ValueError(f"wire type {wire} not handled")
        fields.append((field, wire, val))
    return fields

# field 1 = interface name, field 2 = in-octets, field 3 = timestamp (ms)
name = b"ge-0/0/0"
msg = (bytes([1 << 3 | 2, len(name)]) + name
       + bytes([2 << 3 | 0]) + encode_varint(150)
       + bytes([3 << 3 | 0]) + encode_varint(1763452800000))
print(msg.hex(" "))
for f in decode(msg):
    print(f)

Output:

0a 08 67 65 2d 30 2f 30 2f 30 10 96 01 18 80 98 e9 af a9 33
(1, 2, 'ge-0/0/0')
(2, 0, 150)
(3, 0, 1763452800000)

The whole message is 20 bytes. The value 150 needs only two bytes (96 01) because varints use 7 bits per byte. The same data as JSON would be several times larger, which is why streaming telemetry uses protobuf.

Streaming telemetry with gNMIc

gnmic -a 192.0.2.10:32767 -u lab -p 'lab123' --skip-verify \
  subscribe \
  --path "/interfaces/interface[name=ge-0/0/0]/state/counters" \
  --mode stream --stream-mode sample --sample-interval 10s
Subscription mode Behaviour
ONCE Send the data once, then close
POLL Send data each time the client polls
STREAM / SAMPLE Send at a fixed interval
STREAM / ON_CHANGE Send only when a value changes (good for state such as oper-status)
STREAM / TARGET_DEFINED The device chooses sample or on-change per leaf

A sensor path is an OpenConfig or native YANG path, such as /interfaces/interface/state/counters/. Path keys go in square brackets: [name=ge-0/0/0].

TIG stack: from counters to a graph

TIG is Telegraf (collects gNMI and writes to the database), InfluxDB (time-series storage) and Grafana (dashboards). Counters arrive as running totals, so something has to turn two samples into a rate. That is what Grafana's non_negative_derivative or a Telegraf processor does:

# Turn two gNMI counter samples into a bit rate, handling 64-bit wrap
WRAP = 2 ** 64

def bps(prev, curr):
    (t0, c0), (t1, c1) = prev, curr        # (timestamp ns, in-octets)
    delta = (c1 - c0) % WRAP               # survives a counter wrap
    return delta * 8 / ((t1 - t0) / 1e9)

samples = [
    (1_763_452_800_000_000_000, 9_000_000_000),
    (1_763_452_810_000_000_000, 9_125_000_000),   # +10 s
    (1_763_452_820_000_000_000, 9_250_000_000),   # +10 s
]
for prev, curr in zip(samples, samples[1:]):
    print(f"{bps(prev, curr) / 1e6:.1f} Mbps")

near_wrap = (0, WRAP - 1_000)
after_wrap = (10_000_000_000, 4_000)               # counter rolled over
print(f"after wrap: {bps(near_wrap, after_wrap):.1f} bps")

Output:

100.0 Mbps
100.0 Mbps
after wrap: 4000.0 bps

gNMI timestamps are nanoseconds since the Unix epoch. Forgetting that is a classic off-by-10⁹ bug.

3. Ansible for Junos

Juniper maintains the juniper.device collection. It connects over NETCONF (port 830) and uses PyEZ underneath, so the Junos device needs no agent.

Module Use
juniper.device.facts Collect device facts
juniper.device.command Run operational commands
juniper.device.rpc Run any Junos RPC
juniper.device.config Load, diff, check and commit configuration
juniper.device.jsnapy Run JSNAPy tests

Supported files

File Role
Inventory (hosts.ini or YAML) Which devices, grouped
ansible.cfg Defaults: inventory path, forks, collections path
Playbook (YAML) Plays and tasks
group_vars/, host_vars/ Variables per group or host
Templates (.j2) Jinja2 configuration templates
Vault files Encrypted variables

A playbook with a Jinja2 template

# site.yml
- name: Push interface descriptions
  hosts: junos
  connection: local
  gather_facts: no
  tasks:
    - name: Render and commit
      juniper.device.config:
        load: merge
        template: templates/interfaces.j2
        vars: "{{ interfaces }}"
        format: text
        comment: "ansible: interface descriptions"
        diff: true
      register: result

    - name: Show the diff
      debug:
        var: result.diff_lines
{# templates/interfaces.j2 #}
interfaces {
{% for ifd in interfaces %}
    {{ ifd.name }} {
        description "{{ ifd.desc }}";
    }
{% endfor %}
}

Run it with --check to get a commit check and diff without committing. Check mode is a frequent exam point.

Vault

ansible-vault encrypt_string 'S3cret!' --name 'ansible_password'
ansible-playbook site.yml --ask-vault-pass

encrypt_string encrypts one variable. ansible-vault encrypt encrypts a whole file. Either way the playbook decrypts at run time when you supply the vault password.

JSNAPy: pre and post checks

JSNAPy takes snapshots of operational state before and after a change and compares them using tests written in YAML:

tests_include:
  - check_bgp_peers

check_bgp_peers:
  - command: show bgp neighbor
  - iterate:
      xpath: //bgp-peer
      id: peer-address
      tests:
        - is-equal: peer-state, Established
          err: "Peer {{post['peer-address']}} is {{post['peer-state']}}"
          info: "Peer {{post['peer-address']}} is Established"
        - no-diff: peer-state
          err: "Peer state changed for {{pre['peer-address']}}"

The id field is how JSNAPy matches the same element across pre and post, and it explains why a missing peer is caught. This plain-Python version shows the logic:

# JSNAPy-style pre/post snapshot check, written in plain Python
import xml.etree.ElementTree as ET

pre = ET.fromstring("""<bgp-information>
  <bgp-peer><peer-address>10.0.0.1</peer-address><peer-state>Established</peer-state></bgp-peer>
  <bgp-peer><peer-address>10.0.0.2</peer-address><peer-state>Established</peer-state></bgp-peer>
  <bgp-peer><peer-address>10.0.0.3</peer-address><peer-state>Established</peer-state></bgp-peer>
</bgp-information>""")
post = ET.fromstring("""<bgp-information>
  <bgp-peer><peer-address>10.0.0.1</peer-address><peer-state>Established</peer-state></bgp-peer>
  <bgp-peer><peer-address>10.0.0.2</peer-address><peer-state>Active</peer-state></bgp-peer>
</bgp-information>""")

def index(root):
    return {p.findtext("peer-address"): p.findtext("peer-state")
            for p in root.iter("bgp-peer")}

before, after = index(pre), index(post)
failed = 0
for peer in sorted(before):
    state = after.get(peer)
    if state is None:
        print(f"FAIL {peer}: missing in post snapshot"); failed += 1
    elif state != "Established":
        print(f"FAIL {peer}: {before[peer]} -> {state}"); failed += 1
    else:
        print(f"PASS {peer}: Established")
print(f"{len(before) - failed} passed, {failed} failed")

Output:

PASS 10.0.0.1: Established
FAIL 10.0.0.2: Established -> Active
FAIL 10.0.0.3: missing in post snapshot
1 passed, 2 failed
JSNAPy mode What it does
--snap pre / --snap post Take a snapshot only
--check pre post Compare two stored snapshots with the tests
--snapcheck Take a snapshot and test it at once (no comparison)
--diff pre post Show raw differences, no tests

4. Junos automation scripts

All four script types run on the device. They can be written in SLAX, XSLT or Python.

Type Triggered by Directory Typical use
Commit script Every commit /var/db/scripts/commit/ Enforce policy, emit warnings or errors, change the candidate
Op script An operator running op <name> /var/db/scripts/op/ Custom CLI commands and reports
Event script An event policy /var/db/scripts/event/ React to syslog events, such as a link going down
SNMP script An SNMP get on a custom OID /var/db/scripts/snmp/ Expose computed values over SNMP

A Python commit script

# /var/db/scripts/commit/check-intf.py  (runs on Junos, not locally)
from junos import Junos_Configuration
import jcs

def main():
    for ifd in Junos_Configuration.xpath("./interfaces/interface"):
        name = ifd.findtext("name")
        if ifd.find("description") is None:
            jcs.emit_warning(f"{name}: no description")
        mtu = ifd.findtext("mtu")
        if mtu and int(mtu) < 1500:
            jcs.emit_error(f"{name}: mtu {mtu} is below 1500")

if __name__ == "__main__":
    main()
set system scripts language python3
set system scripts commit file check-intf.py

A warning lets the commit go through. An error blocks it. The script gets the post-inheritance candidate configuration as XML. This local simulation makes the outcome easy to see:

# What a commit script does, simulated: inspect candidate config, emit warnings/errors
import xml.etree.ElementTree as ET

candidate = ET.fromstring("""<configuration>
  <interfaces>
    <interface><name>ge-0/0/0</name><description>to-core-1</description></interface>
    <interface><name>ge-0/0/1</name></interface>
    <interface><name>ge-0/0/2</name><mtu>1200</mtu></interface>
  </interfaces>
</configuration>""")

results = []
for ifd in candidate.findall("./interfaces/interface"):
    name = ifd.findtext("name")
    if ifd.find("description") is None:
        results.append(("warning", f"{name}: no description"))
    mtu = ifd.findtext("mtu")
    if mtu and int(mtu) < 1500:
        results.append(("error", f"{name}: mtu {mtu} is below 1500"))

for level, text in results:
    print(f"{level}: {text}")
print("commit", "blocked" if any(l == "error" for l, _ in results) else "allowed")

Output:

warning: ge-0/0/1: no description
warning: ge-0/0/2: no description
error: ge-0/0/2: mtu 1200 is below 1500
commit blocked

Commit scripts can also make changes. A transient change (jcs.emit_change(..., "transient-change")) is applied to the checkout configuration but never appears in the candidate. It needs set system scripts commit allow-transients. A persistent change is written into the configuration like a normal edit.

An event policy that calls an event script

set event-options policy LINK-DOWN events snmp_trap_link_down
set event-options policy LINK-DOWN attributes-match snmp_trap_link_down.interface-name matches "^ge-0/0/0$"
set event-options policy LINK-DOWN then event-script collect-diag.py
set event-options event-script file collect-diag.py python-script-user lab

The Junos Automation Scripting User Guide has the full commit, op, event and SNMP script reference, including the jcs functions.

5. YANG and OpenConfig

YANG is the modelling language that defines configuration and state data. NETCONF, RESTCONF and gNMI all carry data described by YANG.

container interface-settings {
  leaf name {
    type string;
  }
  leaf mtu {
    type uint16 {
      range "256..9216";
    }
    default 1514;
  }
  leaf enabled {
    type boolean;
    default true;
  }
  leaf-list tags {
    type string;
  }
}
YANG statement Meaning
container Groups nodes; has no value itself
list Repeating entries, identified by a key
leaf One value with a type
leaf-list A list of values with no key
typedef / grouping / uses Reusable types and node sets
config false Operational state, read-only
augment / deviation Add to a model / say where a device differs from it

Junos has native YANG models, which match the CLI hierarchy exactly, and supports OpenConfig models, which are vendor-neutral. An OpenConfig path such as /interfaces/interface/config/mtu is translated into the Junos configuration. When a device can't fully implement a model, it publishes deviation statements, and that is a common exam detail.

Study plan for JN0-423

Week Focus Lab
1 Platform overview, YANG Read native and OpenConfig models; map paths to CLI
2 gRPC and gNMI Enable gRPC, run gNMIc Get and Subscribe in each mode
3 Telemetry Build a Telegraf + InfluxDB + Grafana stack from a vSRX or vMX
4 Ansible Facts, config with templates, check mode, Vault
5 JSNAPy Pre/post checks around a BGP or interface change
6 Automation scripts One commit, op, event and SNMP script each
7 Review Practice questions, weak spots, re-read the objectives

vJunos-router, vJunos-switch or an evaluation vSRX runs on a laptop and are enough for every lab above. For timed practice, the JN0-423 sample questions on NWExam match the exam's multiple-choice format. Go back to the docs for any question you got right by guessing.

Common traps

Trap The correct idea
Thinking gNMI runs over NETCONF gNMI is a gRPC service over HTTP/2
Running clear-text gRPC in production Use ssl with certificates; clear text is for labs only
Expecting ON_CHANGE for counters Counters change constantly; use SAMPLE
jcs.emit_warning blocking a commit Only emit_error blocks it
Transient changes without allow-transients The commit fails without that knob
--snapcheck comparing two snapshots It tests one snapshot; --check compares
Treating Terraform like a playbook Terraform is declarative and state-based

FAQ

How many questions are on the JN0-423 exam?

65 multiple-choice questions in 90 minutes. Pass/fail is shown as soon as you finish.

Do I need JNCIA-DevOps before JN0-423?

Yes. JNCIA-DevOps (JN0-224) is the prerequisite for JNCIS-DevOps, and the certification is valid for three years.

Which Junos version is JN0-423 based on?

Junos OS 24.4, according to Juniper's certification overview.

Do I need to write code in the exam?

No. All questions are multiple choice. You do need to read Python, YAML, Jinja2, SLAX and YANG snippets and predict what they do, so writing a little of each in a lab helps a lot.

What is the best lab setup for JN0-423?

A laptop running vJunos or vSRX, plus Ansible with the juniper.device collection, gNMIc, JSNAPy, and a Telegraf, InfluxDB and Grafana stack in containers. That covers every objective.

Exam-day checklist

  • Know the four gNMI RPCs and the three subscription modes, including SAMPLE vs ON_CHANGE.
  • Recognise protobuf as binary, field-numbered and schema-dependent.
  • Remember the TIG roles: Telegraf collects, InfluxDB stores, Grafana shows.
  • Match each juniper.device module to its job, and remember that --check means commit check without commit.
  • Know ansible-vault encrypt_string vs encrypt.
  • Know the JSNAPy modes: --snap, --check and --snapcheck.
  • Know the four script types, their triggers and their directories.
  • Remember that emit_warning allows the commit, emit_error blocks it, and transient changes need allow-transients.
  • Read YANG: container, list with key, leaf, leaf-list, config false, deviation.
  • Place each tool on MGD or JSD, and remember Terraform is declarative.
  • Check Pearson VUE's ID rules for your country and arrive 15 minutes early, or run the system check the day before an online exam.
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?