跳转至

ServiceNow

概述

OpenSRE 连接到 ServiceNow,以便 CLI 和交互式 shell 能够回答关于你的实例的配置问题——例如 opensre integrations verify servicenow,以及类似“ServiceNow 是否已配置?”的 shell 问题。

ServiceNow 目前是一个配置与验证集成。它不会注册智能体查询工具。

先决条件

  • 一个 ServiceNow 实例 URL(免费的开发者实例即可)
  • 一个对 sys_user 表具有读取权限的用户(用于实时连通性检查)

设置

选项 1:Interactive CLI

opensre integrations setup servicenow

选项 2:环境变量

export SERVICENOW_INSTANCE_URL=https://dev12345.service-now.com
export SERVICENOW_USERNAME=admin
export SERVICENOW_PASSWORD=your-password

当未设置环境变量时,SERVICENOW_PASSWORD 也会从 ~/.opensre/credentials.json 中解析(向导会将其存储在那里)。

选项 3:持久化存储

{
  "version": 1,
  "integrations": [
    {
      "id": "servicenow-prod",
      "service": "servicenow",
      "status": "active",
      "credentials": {
        "instance_url": "https://dev12345.service-now.com",
        "username": "admin",
        "password": "your-password"
      }
    }
  ]
}
字段 描述
instance_url 必需。 实例 URL(例如 https://dev12345.service-now.com)。必须使用 https://——纯 http:// 仅对 localhost/loopback 接受。
username 必需。 用于 HTTP Basic 身份验证的 ServiceNow 用户名
password 必需。 该用户的密码

凭据

使用专用的 ServiceNow 用户,并仅授予读取 sys_user 单行数据所需的最低角色(例如 itil)。建议使用 opensre integrations setup servicenow,这样密码会保留在 ~/.opensre/credentials.json 中,而不是 .env。

工具

无。ServiceNow 仅用于配置和验证。交互式 shell 仍可通过运行验证器来回答“ServiceNow 是否已配置?”。

验证

opensre integrations verify servicenow

验证是一项实时检查:它会校验 URL 的形式(HTTPS 或回环地址),并调用 GET …/api/now/table/sys_user?sysparm_limit=1。

成功时的预期详情:

ServiceNow connected as <username> at https://dev12345.service-now.com.

你也可以向交互式 shell 提问:

> Is ServiceNow configured?

故障排查

症状 修复
状态 missing 通过上述任一设置选项设置 instance_url、username 和 password
401 未授权 检查用户名和密码组合
403 禁止访问 用户已通过身份验证,但无法读取 sys_user——请授予具有表读取权限的角色(例如 itil)
404 未找到 验证实例 URL(包含 https://,不含路径)
开发者实例无法访问 免费开发者实例在闲置后会休眠——请从开发者门户唤醒它并重试

安全

  • 使用具有最低读取角色的专用 ServiceNow 用户。
  • 建议使用 opensre integrations setup servicenow,这样密码会保留在 ~/.opensre/credentials.json 中。
  • 定期轮换密码,并在不再需要该集成时将其移除。

本页原文 Markdown:在 AtomGit 查看·内容源自开源项目 op/opensre