在 RHEL 中使用 goose 实现主机运维

文章目录

  • [安装 goose](#安装 goose)
  • [配置 goose 的 provider](#配置 goose 的 provider)
    • [使用 qwen 作为 provider](#使用 qwen 作为 provider)
    • [使用 command-line-assistant 作为 provider](#使用 command-line-assistant 作为 provider)
    • 切换使用的模型
  • [使用 goose](#使用 goose)
  • 参考

安装 goose

  1. 确认 RHEL 版本是 RHEL 至少是 10.2 或 9.8 版本。本文使用的是 RHEL 10.2。
bash 复制代码
$ cat /etc/redhat-release 
Red Hat Enterprise Linux release 10.2 (Coughlan)
  1. 配置 RHEL 10 的 YUM Repo。
bash 复制代码
$ subscription-manager repos --enable=rhel-10-for-$(arch)-extensions-rpms
  1. 安装 goose-redhat 软件包。goose-redhat 包中不但包括了 goose,还包括 goose-proxy 和 goose-proxy-selinux。
bash 复制代码
$ dnf install -y goose-redhat
  1. 为了 goose 的配置使生效,启用一个新的 shell 会话。
  2. (可选)参照《RHEL - 在离线的 RHEL 10 中部署 Lightspeed》一文安装 RHEL Lightspeed 的 command-line-assistant 工具。说明:goose 可以直接调用本机的 command-line-assistant,也可调用多种大语言模型。

配置 goose 的 provider

  1. 运行命令,配置 goose。
bash 复制代码
$ goose configure
  1. 在 Share anonymous usage data to help improve goose? 步骤选择合适的选项。
  2. 在 How would you like to set up your provider? 步骤选择 Manual Configuration (Choose a provider and enter credentials manually)

使用 qwen 作为 provider

  1. 可在另一个终端窗口先确认当前 qwen 模型可以访问。
bash 复制代码
$ URL=<YOUR_HOST>
$ TOKEN=<YOUR_ACCESS_TOKEN>
$ curl -sk $URL/v1/completions \
  -H "Authorization: Bearer ${TOKEN}" \
  -H "Content-Type: application/json" \
  -d '{"model":"Qwen3.6-35B-A3B","prompt":"Red Hat OpenShift AI is","max_tokens":128}' | jq
{
  "id": "cmpl-b4ee7eea9082e3ed",
  "object": "text_completion",
  "created": 1792737965,
  "model": "qwen38-27b-fp8",
  "choices": [
    {
      "stop_reason": null,
      "token_ids": null,
      "prompt_logprobs": null,
      "prompt_token_ids": null,
      "routed_experts": null,
      "finish_reason": "length",
      "index": 0,
      "text": " an AI platform that enables AI practitioners, data scientists, and developers to create, deploy, and manage AI models and pipelines in a secure and efficient manner.\nFor OpenShift AI 2.13, it includes OpenShift Pipelines, an event-driven, GitOps-native, continuous integration/continuous delivery (CI/CD) framework that enables developers to build, test, and deploy applications to any platform.\nOpenShift AI supports both the v1 and the v2 pipelines engine (TektonCD), and allows users to opt in to either engine. The v1 pipeline engine was removed in 2.14. The",
      "logprobs": null
    }
  ],
  "usage": {
    "completion_tokens": 128,
    "prompt_tokens": 6,
    "total_tokens": 134,
    "completion_tokens_details": null,
    "prompt_tokens_details": null
  },
  "system_fingerprint": "vllm-0.28.0-tp4-518e74d4",
  "service_tier": null,
  "kv_transfer_params": null,
  "ec_transfer_params": null,
  "metrics": null
}
  1. 在原有终端的 What would you like to configure? 步骤中选择 Configure Providers。
  2. 在 Which model provider should we use? 步骤选择 OpenAI (GPT-4 and other OpenAI models, including OpenAI compatible ones) 。
  3. 在 Would you like to set OPENAI_API_KEY? (optional) 步骤选择 Yes。
  4. 在 Enter value for OPENAI_API_KEY 后提供访问 qwen 模型的 OPENAI_API_KEY 内容。
  5. 在 Would you like to configure advanced settings? 步骤选择 Yes。
  6. 跳过 Enter OPENAI_BASE_URL (optional, press Enter to skip) 步骤。
  7. 在 Provider OpenAI requires OPENAI_HOST, please enter a value 步骤提供访问 Qwen 模型的主机地址。
  8. 在 Provider OpenAI requires OPENAI_BASE_PATH, please enter a value 步骤中接受默认值。
  9. 跳过 Enter OPENAI_ORGANIZATION (optional, press Enter to skip) 步骤。
  10. 跳过 Enter OPENAI_PROJECT (optional, press Enter to skip) 步骤。
  11. 在 Would you like to set OPENAI_CUSTOM_HEADERS? (optional) 步骤选择 No。
  12. 在 Enter OPENAI_TIMEOUT (optional, press Enter to skip) 步骤中接受默认值。
  13. 如果前面提供的配置有效,在 Select a model 步骤中可以显示出能访问的模型。可以选择一个可用的模型。
  14. 最后 goose 会验证所有配置,并将其保存到当前用户下的 ~/.config/goose/config.yaml 配置文件中。
  15. 查看 config.yaml 配置文件中已包含以下内容。
bash 复制代码
$ cat ~/.config/goose/config.yaml
。。。
OPENAI_HOST: https://litemaas.rhoai.rh-aiservices-bu.com
OPENAI_BASE_PATH: v1/chat/completions
OPENAI_TIMEOUT: '600'
active_provider: openai
providers:
  openai:
    enabled: true
    model: Qwen3.6-35B-A3B
    configured: true
  1. 执行 goose 命令,确认使用了前面选择的 Qwen3.6-35B-A3B 模型。
bash 复制代码
$ goose 

注意:可以用环境变量覆盖 config.yml 中的配置。

bash 复制代码
$ export GOOSE_PROVIDER=openai
$ export GOOSE_MODEL=Qwen3.6-35B-A3B
$ export OPENAI_HOST=<YOUR_HOST>
$ export OPENAI_API_KEY=<YOUR_API_KEY>
$ goose session

使用 command-line-assistant 作为 provider

注意:首先确保当前 RHEL 已安装了 command-line-assistant。另外在 goose configure 的 provider 列表中默认是没有 command-line-assistant 的,只有在创建以下 custom provider 后才会出现(创建过程:系统会自动发现并创建,也可手动按以下文件命和内容创建)。

  1. 确认手动或系统已自动在 ~/.config/goose/custom_providers 目录下创建了含有以下内容的 rhel_cla.json 文件。
json 复制代码
$ cat ~/.config/goose/custom_providers/rhel_cla.json
{
    "name": "rhel_cla",
    "engine": "openai",
    "display_name": "RHEL command line assistant",
    "description": "Inference provided by Red Hat with RHEL specific knowledge",
    "api_key_env": "",
    "base_url": "http://127.0.0.1:7080",
    "base_path": "v1/chat/completions",
    "models": [
        {
            "name": "RHEL-command-line-assistant",
            "context_limit": 128000,
            "input_token_cost": null,
            "output_token_cost": null,
            "currency": null,
            "supports_cache_control": null
    }
  ],
    "headers": {},
    "timeout_seconds": null,
    "supports_streaming": true,
    "requires_auth": true
}
  1. 执行配置命令。
bash 复制代码
$ goose configure
  1. 先进入 Configure Providers,然后在 Which model provider should we use? 步骤中选择 RHEL command line assistant。
  2. 其他步骤接受默认配置,直到完成配置即可。
  3. 执行命令,确认使用的是 RHEL command line assistant
bash 复制代码
$ goose run -t "What is the current OS version and kernel release?"

切换使用的模型

  1. 在 goose 提示符后输入以下命令,可以切换当前会话使用的 provider 模型。
bash 复制代码
> /model Qwen3.6-35B-A3B

mode: Session model switched from 'RHEL-command-line-assistant' to 'Qwen3.6-35B-A3B' for provider 'rhel_cla'

使用 goose

单次模式

  1. 每执行以下命令可完成一次 goose 调用。
bash 复制代码
$ goose run -t "What is the current OS version and kernel release?"
  1. 执行完会回到 bash。
bash 复制代码
    __( O)>  ● new session · openai Qwen3.6-35B-A3B
   \____)    20261023_4 · /root/.config
     L L     goose is ready

  ────────────────────────────────────────
  ▸ shell
    command: cat /etc/os-release 2>/dev/null | head -5; echo "---"; uname -r

    NAME="Red Hat Enterprise Linux"
    VERSION="10.2 (Coughlan)"
    RELEASE_TYPE=stable
    ID="rhel"
    ID_LIKE="centos fedora"
    ---
    6.12.0-211.67.1.el10_2.x86_64


Here's the current system info:

**OS:** Red Hat Enterprise Linux 10.2 (Coughlan)
**Kernel release:** 6.12.0-211.67.1.el10_2.x86_64

交互模式

  1. 运行 goose 命令进入交互模式,界面停在 > Enter to send · Ctrl+J newline 提示符处。
bash 复制代码
$ goose
 
    __( O)>  ● new session · rhel_cla RHEL-command-line-assistant
   \____)    20261022_8 · /root
     L L     goose is ready
⚠️ This tool uses AI technology. Do not include any personal information or other sensitive information in your input. Interactions may be used to improve Red Hat's products or services.

  ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ 0% 0/128k
> Enter to send · Ctrl+J newline
  1. 在提示符后输入 What is the current OS version and kernel release? 命令,然后查看返回结果。
bash 复制代码
> What is the current OS version and kernel release?
 
 
  ────────────────────────────────────────
  ▸ shell
    command: cat /etc/redhat-release && uname -r
 
    Red Hat Enterprise Linux release 10.2 (Coughlan)
    6.12.0-211.67.1.el10_2.x86_64
The current OS version is Red Hat Enterprise Linux release 10.2 (Coughlan) and the kernel release is 6.12.0-211.67.1.el10_2.x86_64.
 
**Sources:**
- None
  ⏱ 9.47s
Always review AI-generated content prior to use.
  ━╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ 7% 9k/128k

参考

https://access.redhat.com/articles/7142302

https://www.redhat.com/en/blog/supercharge-rhel-troubleshooting-agentic-ai-introducing-goose

https://www.redhat.com/en/blog/smarter-troubleshooting-new-mcp-server-red-hat-enterprise-linux-now-developer-preview

https://developers.redhat.com/articles/2026/10/08/manage-rhel-mcp-servers-and-red-hat-lightspeed

https://github.com/rhel-lightspeed/goose

https://goose-docs.ai/docs/quickstart

https://www.youtube.com/watch?v=ik4q9_NMQPo

https://www.youtube.com/watch?v=Pz1CCvJdBSk

相关推荐
by2099924 分钟前
Linux 软硬链接与文件删除机制
linux·服务器
我不会起名字3222 小时前
eBPF 与 perf 性能观测:On-CPU、Off-CPU 火焰图与内核探针的 4 个边界
linux·云原生·ebpf·perf·性能观测
极创信息2 小时前
信创国产化适配流程全解:从环境矩阵到测试证明的完整路径
运维·人工智能·http·wireshark·健康医疗
俊俊几年的2 小时前
RK3588 开发板详解:硬件优势与嵌入式 Linux 学习路线
linux·c++·嵌入式
jason_renyu3 小时前
Playwright 入门与实操:从安装、定位、断言到自动发博客,把浏览器自动化讲明白
运维·python·自动化·前端开发·浏览器自动化·playwright·e2e测试
信安IT租赁3 小时前
小公司服务器用户与权限管理:chmod/chown/用户组从零理清
linux·运维·服务器
科力锐品牌君3 小时前
信创进入核心系统深水区:X86 与国产架构长期并存,如何落地统一灾备?
运维·网络·数据库·数据安全·灾备
Kira Skyler4 小时前
linux /proc/kallsystem 构建与解析
linux
岁月蹉跎的一杯酒5 小时前
Linux V4L2 嵌入式相机驱动点亮
linux·数码相机·isp
yyuuuzz5 小时前
跨境电商云服务器,五个店铺挤一台机器
运维·服务器·人工智能·云服务器