Cisco IOS-XE
Certified
Enterprise Edition
Check, upgrade and configure Cisco IOS-XE devices (Catalyst 9000, ISR/ASR, C8000v) over SSH, with RESTCONF for structured reads.
Cisco IOS-XE
Check, upgrade and configure Cisco IOS-XE devices (Catalyst 9000, ISR/ASR, C8000v) over SSH, with RESTCONF for structured reads.
tasks
How to use the Cisco plugin
Automate Cisco network devices from Kestra. The plugin is organised by product line, each in its own sub group. Today it
covers IOS-XE (io.kestra.plugin.ee.cisco.iosxe): Catalyst 9000, ISR/ASR and C8000v. The first target is a
standalone Catalyst 9500 core in install mode. Connection handling, secret masking, typed errors and the check result are
shared (io.kestra.plugin.ee.cisco.common) so other Cisco platforms can reuse them.
Authentication
Every IOS-XE task connects to the device over SSH (the CLI), with credentials you should keep in secrets and, to avoid repeating them, in plugin defaults.
| Property | Required | Notes |
|---|---|---|
host, port |
host |
Device name or IP, SSH port 22 by default. |
username |
yes | The account needs privilege 15, or use enableSecret. |
password or privateKey (+ privateKeyPassphrase) |
one of them | Secrets. |
enableSecret |
no | Secret. Used when the login lands in user EXEC mode (host>). |
hostKeyFingerprint |
yes, unless opted out | SHA256 fingerprint of the device host key (SHA256: ..., as printed by ssh-keygen -lf). Host key verification is on by default. |
disableHostKeyVerification |
no | Explicit opt-out for labs. The credentials are then exposed to a man-in-the-middle. |
connectTimeout, commandTimeout |
no | 30 seconds and 2 minutes. |
The client negotiates both default algorithm sets of Catalyst 9000: 17.9 (still offers diffie-hellman-group14-sha1)
and 17.11+ (curve25519, group14/16-sha2). The device only offers RSA host keys.
Secrets are masked on a best-effort basis in logs and outputs: command echoes, error messages and every configuration
(enable secret, username ... secret|password, snmp-server community|host, key/key-string, TACACS+/RADIUS keys,
pre-shared keys, IS-IS area and domain passwords, any password <value>, certificates become <masked>, the line is
kept so diffs still show a change). The masker knows the common IOS-XE syntaxes, not every feature of every release:
review the output of a configuration that uses an unusual secret syntax before sharing it.
Tasks
All tasks share the connection properties above. Read tasks (Facts, Check, GetConfig) also take
transport: SSH | RESTCONF.
| Task | What it does |
|---|---|
RunCommands |
Runs up to 50 show, dir and verify commands. Anything else is rejected before connecting. Each raw output is stored in internal storage (results[].uri, masked); the commands with a parser also return a structured parsed result inline. |
Facts |
Version, model, boot mode (INSTALL/BUNDLE), packages and their state, auto-abort timer, restart time, bootflash space. |
Check |
phase: PRE or POST. Checks flash, redundancy, interface and install; returns version, modelName, bootupTimestamp, status (ok/ko), checksPassed, checksFailed[{check, message}] (one entry per failed check, problems joined by ; ), a snapshot file in PRE and, in POST, a configDiff file. |
TransferImage |
copy over HTTP, HTTPS or SCP to bootflash, then verify /sha512 (or /md5). Idempotent. Returns imageFile, copySkipped and sizeBytes. |
Activate |
install add: stage and validate the image, no reload. Returns imageFile, alreadyAdded, previousBootImage and previousVersion. |
Reload |
install activate ... auto-abort-timer: reload exactly once onto the new image and wait for the device. Takes the pre-check snapshot (or previousBootupTimestamp), returns alreadyReloaded. |
Commit |
install commit: make the new image permanent. With removePreviousImage: true (needs snapshot) it also removes the previous image and returns removedImage. |
Rollback |
install abort, or install rollback to committed / to id. Takes the pre-check snapshot, returns previousImage, alreadyReloaded and bootupTimestamp. |
Cleanup |
install remove inactive. Only after the commit. |
GetConfig |
Normalised, masked running configuration as a file. |
DiffConfig |
show archive config differences between a configuration and the running one. |
ApplyConfig |
configure replace ... force revert trigger error timer, then configure confirm. dryRun returns the diff only. |
Activate, reload, commit, rollback
On Catalyst 9000, install activate reloads the switch, and the one-shot install add file X activate commit reloads
and commits in one step. The plugin splits it so a failed post-check can still roll back:
| Step | Task | IOS-XE command | Reloads |
|---|---|---|---|
| stage | Activate |
install add file bootflash: <img> |
no |
| reload | Reload |
install activate file bootflash: <img> auto-abort-timer <30-1200> prompt-level none |
yes, exactly once |
| commit | Commit |
install commit (also stops the auto-abort timer) |
no |
| rollback, uncommitted | Rollback |
install abort |
yes |
| rollback, committed | Rollback |
install rollback to committed or install rollback to id <n> |
yes |
An activated, uncommitted image survives one reload but not a second one, so "never reload twice" is enforced by the
plugin, not just documented. Reload receives the pre-check snapshot (or only its bootupTimestamp as
previousBootupTimestamp) and reads the device before sending anything:
- the target already runs:
alreadyReloaded: true, nothing sent. Only the running version proves the reload; - the boot time is newer than the baseline but the device does not run the target (an unrelated reboot, or the
auto-abort timer fired):
CISCO_UNEXPECTED_STATE, nothing sent; - the device has not rebooted and an install is in progress (RESTCONF
sys-activity; withoutrestconf, a running auto-abort timer, aUpackage at a version other than the running one, or the target already inU/C):InstallInProgressException, nothing sent; - the target is not added, or the device runs neither the pre-check version nor the target: refused;
- otherwise it reloads.
Rollback does the same with the version in the pre-check snapshot: when the device already runs it, it returns
alreadyReloaded: true. Without restconf, when it runs that version but a U package exists at another version (an
activation whose executor died before the reboot), it fails with InstallInProgressException. A U package at the
running version is a leftover and does not block; with restconf, sys-activity decides. This rule has not been
validated on hardware yet. The guards read the device, not Kestra, so they hold after an executor kill or a retry.
Do not set retry on Reload or Rollback: decide in the flow what to do after a failure. If the device does not
come back within reloadTimeout, the failure says activateSent=true.
Unlike the Arista EOS plugin there is no separate wait task: Reload and Rollback wait for the device to come back
themselves (reloadTimeout, bootGracePeriod), so no WaitForReturn step is needed on IOS-XE.
bootupTimestamp is epoch seconds like on EOS. It is exact over RESTCONF (ISO boot-time) and over the CLI when the
device prints its restart time in UTC or GMT. A CLI zone such as CST or IST is ambiguous, so the time is then derived
from the device uptime and the worker clock instead of being guessed: precision about one minute (the uptime has a one
minute resolution). Boot times are compared with a two minute tolerance, and the RESTCONF value comes from the device
clock while the derived one comes from the worker clock: keep the device clock synchronised (NTP), a larger skew
makes Reload refuse. The zone names UTC and GMT are trusted to mean offset 0 (show version prints no offset).
The auto-abort timer is always set explicitly (default 120 minutes, allowed 30 to 1200): if the post-check takes too
long and nobody commits, the device goes back to the previous version by itself. Commit detects that and fails
instead of committing the old version.
Typed errors
Messages start with a stable code, so flows can tell retryable failures from final ones:
| Code | Meaning | Retry |
|---|---|---|
CISCO_DEVICE_UNREACHABLE |
TCP, SSH or HTTPS failure, timeout, connection refused. | yes |
CISCO_AUTH_FAILURE |
Credentials or enable secret rejected. During the bootGracePeriod after a reload it only means "not back yet". |
never |
CISCO_IOSXE_ACTIVATE_FAILED |
reason= NO_SPACE, BUNDLE_MODE, MISSING_FILE, CHECKSUM, INSTALL_IN_PROGRESS, PLATFORM_MISMATCH or UNKNOWN (carries the raw FAILED: line). |
no |
CISCO_IOSXE_ROLLBACK_FAILED |
FAILED: line, or wrong version after the boot. No second attempt. |
no |
CISCO_IOSXE_INSTALL_IN_PROGRESS |
Raised by the Reload and Rollback guards. |
flow decides |
CISCO_HOST_KEY_MISMATCH, CISCO_COMMAND_REJECTED, CISCO_UNSUPPORTED_TOPOLOGY, CISCO_UNEXPECTED_STATE... |
Configuration or device state problems. | no |
Device prerequisites
- IOS-XE in install mode (
boot system flash bootflash: packages.conf). Bundle mode is refused withBUNDLE_MODE; converting is not automated. - SSH version 2 with an RSA host key;
hostKeyFingerprintfrom it. The account has privilege 15 (orenableSecret). terminal length 0andterminal width 511are sent by the plugin; no change is needed on the device.- The switch reaches the image host over HTTP, HTTPS or SCP (
TransferImage). A password containing@is refused. archivewithpath bootflash:forApplyConfig(revert timer) and, if the lab shows it is needed,DiffConfig.ip scp server enableforDiffConfig/ApplyConfigwhen they upload a configuration.- Standalone devices only. Stacks and StackWise Virtual pairs are detected and rejected: ISSU/SVL is not supported.
- Install-mode upgrades are validated on Catalyst 9300/9500; the connection,
RunCommands,Factsand configuration tasks are platform agnostic (the parsers read both the switch and the router layout ofshow version).
RESTCONF for structured reads
Facts, Check and GetConfig accept transport: RESTCONF. They return the same outputs and the same check
result as over SSH, but read the Cisco-IOS-XE YANG oper models instead of parsing CLI output, so they do not break when
a release changes a show layout. Prefer it when the device exposes the models; keep SSH otherwise.
Device prerequisites: restconf, ip http secure-server, AAA (aaa new-model with login and exec authorization)
and a privilege-15 user. Configure the restconf property: port (443) and caPem when the device certificate is
self-signed or signed by a private CA. Certificate verification is never disabled, and the host must match the
certificate. HTTPS only, basic authentication with the task credentials (or restconf.username/password).
- Read-only: install, reload, commit, rollback, cleanup, transfer and configuration changes stay on SSH.
- A leaf that a release does not expose is read from the CLI for that field (SSH credentials are still needed).
ReloadandRollbackacceptrestconftoo: the guard then uses the install activity reported byCisco-IOS-XE-install-oper(sys-activity) instead of the CLI heuristic. It fails closed: whenrestconfis set andsys-activitycannot be read, the task raisesInstallActivityUnknownExceptionand sends nothing.- The install models were checked against the
Cisco-IOS-XE-install-operYANG of 17.12.1; they have not been captured from a device yet. The remaining oper models are read tolerantly and fall back to the CLI. - A snapshot records its transport. A
POSTcheck refuses a snapshot taken with the other transport, and the RESTCONF running configuration is JSON, so it is only diffed against RESTCONF snapshots.
Pair upgrade blueprint
Two redundant cores: the backup first, the primary only after the backup passed its post-check. Each core goes through
pre-check, image transfer, install add, reload, post-check and then commit (and clean up) or rollback.
Every device has its own SSH host key, so the blueprint reads the fingerprint from one secret per host, named
HOST_KEY_ followed by the host name in upper case with dots and dashes as underscores:
HOST_KEY_CORE1_EXAMPLE_NET and HOST_KEY_CORE2_EXAMPLE_NET for the two cores below. A single shared secret would
make the second core fail with CISCO_HOST_KEY_MISMATCH.
id: cisco_iosxe_pair_upgrade
namespace: company.network
variables:
image: cat9k_iosxe.17.12.03.SPA.bin
version: 17.12.3
tasks:
- id: upgrade_each_core
type: io.kestra.plugin.core.flow.ForEach
values: ["core2.example.net", "core1.example.net"]
concurrencyLimit: 1
tasks:
- id: pre_check
type: io.kestra.plugin.ee.cisco.iosxe.Check
host: "{{ taskrun.value }}"
username: automation
password: "{{ secret('CISCO_PASSWORD') }}"
enableSecret: "{{ secret('CISCO_ENABLE_SECRET') }}"
hostKeyFingerprint: "{{ secret('HOST_KEY_' ~ (taskrun.value | replace({'.': '_', '-': '_'}) | upper)) }}"
phase: PRE
checks: [FLASH, REDUNDANCY, INTERFACE, INSTALL]
redundancyInterface: Port-channel11
image: "{{ vars.image }}"
- id: stop_if_unhealthy
type: io.kestra.plugin.core.flow.If
condition: "{{ outputs.pre_check[taskrun.value].status == 'ko' }}"
then:
- id: fail_pre_check
type: io.kestra.plugin.core.execution.Fail
errorMessage: "Pre-check failed on {{ taskrun.value }}: {{ outputs.pre_check[taskrun.value].checksFailed }}"
- id: transfer
type: io.kestra.plugin.ee.cisco.iosxe.TransferImage
host: "{{ taskrun.value }}"
username: automation
password: "{{ secret('CISCO_PASSWORD') }}"
enableSecret: "{{ secret('CISCO_ENABLE_SECRET') }}"
hostKeyFingerprint: "{{ secret('HOST_KEY_' ~ (taskrun.value | replace({'.': '_', '-': '_'}) | upper)) }}"
imageUrl: "https://images.example.net/cisco/{{ vars.image }}"
expectedHash: "{{ secret('CAT9K_IMAGE_SHA512') }}"
- id: add
type: io.kestra.plugin.ee.cisco.iosxe.Activate
host: "{{ taskrun.value }}"
username: automation
password: "{{ secret('CISCO_PASSWORD') }}"
enableSecret: "{{ secret('CISCO_ENABLE_SECRET') }}"
hostKeyFingerprint: "{{ secret('HOST_KEY_' ~ (taskrun.value | replace({'.': '_', '-': '_'}) | upper)) }}"
image: "{{ vars.image }}"
targetVersion: "{{ vars.version }}"
- id: reload
type: io.kestra.plugin.ee.cisco.iosxe.Reload
host: "{{ taskrun.value }}"
username: automation
password: "{{ secret('CISCO_PASSWORD') }}"
enableSecret: "{{ secret('CISCO_ENABLE_SECRET') }}"
hostKeyFingerprint: "{{ secret('HOST_KEY_' ~ (taskrun.value | replace({'.': '_', '-': '_'}) | upper)) }}"
image: "{{ vars.image }}"
targetVersion: "{{ vars.version }}"
snapshot: "{{ outputs.pre_check[taskrun.value].snapshot }}"
autoAbortTimer: PT60M
- id: post_check
type: io.kestra.plugin.ee.cisco.iosxe.Check
host: "{{ taskrun.value }}"
username: automation
password: "{{ secret('CISCO_PASSWORD') }}"
enableSecret: "{{ secret('CISCO_ENABLE_SECRET') }}"
hostKeyFingerprint: "{{ secret('HOST_KEY_' ~ (taskrun.value | replace({'.': '_', '-': '_'}) | upper)) }}"
phase: POST
checks: [REDUNDANCY, INTERFACE, INSTALL]
redundancyInterface: Port-channel11
targetVersion: "{{ vars.version }}"
snapshot: "{{ outputs.pre_check[taskrun.value].snapshot }}"
- id: commit_or_rollback
type: io.kestra.plugin.core.flow.If
condition: "{{ outputs.post_check[taskrun.value].status == 'ok' }}"
then:
- id: commit
type: io.kestra.plugin.ee.cisco.iosxe.Commit
host: "{{ taskrun.value }}"
username: automation
password: "{{ secret('CISCO_PASSWORD') }}"
enableSecret: "{{ secret('CISCO_ENABLE_SECRET') }}"
hostKeyFingerprint: "{{ secret('HOST_KEY_' ~ (taskrun.value | replace({'.': '_', '-': '_'}) | upper)) }}"
targetVersion: "{{ vars.version }}"
- id: cleanup
type: io.kestra.plugin.ee.cisco.iosxe.Cleanup
host: "{{ taskrun.value }}"
username: automation
password: "{{ secret('CISCO_PASSWORD') }}"
enableSecret: "{{ secret('CISCO_ENABLE_SECRET') }}"
hostKeyFingerprint: "{{ secret('HOST_KEY_' ~ (taskrun.value | replace({'.': '_', '-': '_'}) | upper)) }}"
targetVersion: "{{ vars.version }}"
else:
- id: rollback
type: io.kestra.plugin.ee.cisco.iosxe.Rollback
host: "{{ taskrun.value }}"
username: automation
password: "{{ secret('CISCO_PASSWORD') }}"
enableSecret: "{{ secret('CISCO_ENABLE_SECRET') }}"
hostKeyFingerprint: "{{ secret('HOST_KEY_' ~ (taskrun.value | replace({'.': '_', '-': '_'}) | upper)) }}"
snapshot: "{{ outputs.pre_check[taskrun.value].snapshot }}"
- id: fail_post_check
type: io.kestra.plugin.core.execution.Fail
errorMessage: "Post-check failed on {{ taskrun.value }}, rolled back: {{ outputs.post_check[taskrun.value].checksFailed }}"