命令选型与 CLI
命令选型指南
公共连接参数
大多数执行类命令都会复用同一组全局连接参数:
执行模式可以写成有序候选列表,例如 --mode 'Enable,Config' 或 --mode 'Root|User'。rauto 会先按所选 Profile 校验候选值,再由 rneter 使用第一个可达模式。
最常用的命令示例
exec
如果需要在指定模式执行:
exec、flow、show 和 config fetch 还支持可重复的 --target、--group、--label/--tag 选择器,并通过 --max-parallel 限制并发。
为原始命令输出启用 TextFSM 解析:
把解析结果导出到 Excel:
--textfsm-excel 本身也会启用 TextFSM 解析,所以这个示例里的 --parse-textfsm 可以省略。
show
常用巡检参数:
跨 saved connection 批量执行 show:
show 默认启用 TextFSM 解析。对象目录、Excel 导出和自定义映射请继续阅读 Show 对象与 TextFSM。
template
只看渲染结果,不实际执行:
flow
同一条 flow 也可以在去重后的多目标集合上执行:
config fetch
命令目录覆盖、归一化与输出规则请查看配置拉取与漂移哈希。
device discover
筛选、TUI 操作和安全导入请查看设备自动发现。
upload
录制与回放
执行类命令普遍支持录制:
回放时可以先列出录制事件:
也可以回放某条命令:
连接配置的推荐做法
临时命令阶段
先创建一次凭证,之后为直连目标传入 --host 和 --credential。
进入重复执行阶段
改用已保存连接:
之后统一使用:
进入多设备阶段
配合 inventory group、tx-workflow 和 orchestrate 使用,会比纯手写连接参数更稳定。
完整的管理命令族
当前 CLI 源码定义的管理面要比前面的快速选型表更大。
rauto profile
根据当前源码,支持:
listautodetect [-v|-vv]show <name>delete-custom <name>copy-builtin <source> <name> [--overwrite]diagnose <name> [--json]
rauto device / rauto connection
根据当前源码,支持:
testlistshow <name>delete <name>add <name>import <file> [--json]discover <targets...> [--port ...] [--probe-credential ...] [--auto-save]discover list [--status ...] [--profile ...] [--port ...] [--search ...] [--json]discover save [host[:port] ...] [--profile ...] [--overwrite]
rauto credential
当前凭证操作包括:
list [--json]show <名称或 ID> [--json]add <名称> [--login-username ...] [--enable] [--json]update <名称或 ID> [--name ...] [--enable|--disable-enable] [--json]import <文件> [--json]delete <名称或 ID>
凭证密钥与连接元数据分离加密。完整生命周期可继续阅读设备凭证。
rauto inventory
当前 inventory 操作包括:
group list [--json]group show <name> [--json]group upsert <name> [--file <path> | --content <json>]group delete <name>
Group 只包含名称、可选说明和已保存连接主机名;变量仍属于执行输入,不再是 inventory group 状态。
rauto session
当前支持:
list [connection-name] [--limit <n>] [--json]show [id] [--json|--raw]delete <id>replay [record-file] [--id <id>] [--list] [--command <cmd>] [--mode <mode>]
rauto blacklist
当前支持:
listadd <pattern>delete <pattern>check <command>
rauto templates
当前支持:
listshow <name>create <name> [--file <path> | --content <template>]update <name> [--file <path> | --content <template>]delete <name>
rauto flow-template
当前支持:
listshow <name>create <name> [--file <path> | --content <toml>]update <name> [--file <path> | --content <toml>]delete <name>
rauto textfsm
根据当前源码,支持:
template listtemplate show <name>template create <name> [--file <path> | --content <textfsm>]template update <name> [--file <path> | --content <textfsm>]template delete <name>mapping list [--profile <profile>]mapping set --profile <profile> --command <command> --template <name>mapping delete --profile <profile> --command <command>
rauto show-object
根据当前源码,支持:
list [--profile <profile>]set --profile <profile> --object <object> --command <command> [--mode <mode>] [--textfsm-template <name>] [--textfsm-mapping-command <command>] [--disabled]delete --profile <profile> --object <object>
rauto tx-workflow template
当前保存的 workflow JSON 模板操作包括:
listshow <name>create <name> [--file <path> | --content <json>]update <name> [--file <path> | --content <json>]delete <name>
rauto orchestrate template
当前保存的 orchestration JSON 模板操作包括:
listshow <name>create <name> [--file <path> | --content <json>]update <name> [--file <path> | --content <json>]delete <name>
rauto backup
当前支持:
create [--output <archive>]restore <archive> [--replace]list
你可能还会用到的管理命令
rauto profile listrauto profile autodetect -vrauto profile show <name>rauto templates listrauto flow-template listrauto textfsm template listrauto show-object list --profile <name>rauto connection listrauto session list <connection-name>rauto blacklist listrauto backup list
录制与回放细节
从当前源码和 README 来看,录制并不是附带能力,而是第一等能力。
当前录制 / 回放相关参数包括:
exec/template/flow/upload/tx/tx-workflow --record-file <path>exec/template/flow/upload/tx/tx-workflow --record-level <key-events-only|full>session replay <record_file> --listsession replay <record_file> --command <cmd> [--mode <mode>]session replay --id <record-id> --list
当前 README 还指出:
- Linux shell 场景下,回放的
SessionEvent::CommandOutput可能包含exit_code key-events-only是最小审计级别full会包含更丰富的 prompt 与状态切换细节
企业级使用建议
把 CLI 当成命令族,而不是单条命令
在企业使用中,更适合把 rauto 理解成一整套命令族,而不是只会跑一条 exec。
典型运维路径通常是:
- 先用
connection add规范目标 - 用
profile autodetect、profile show或profile diagnose验证 profile 行为 - 用
show做只读巡检和 TextFSM 解析 - 用
template或flow执行可复用逻辑 - 用
tx/tx-workflow/orchestrate做受控变更下发 - 用
session list/show/replay与备份做审计和恢复
如果需要解析只读巡检结果,下一步请看 Show 对象与 TextFSM。