在 RHEL 中使用 goose 实现主机运维 文章目录安装 goose配置 goose 的 provider使用 qwen 作为 provider使用 command-line-assistant 作为 provider切换使用的模型使用 goose单次模式交互模式参考安装 goose确认 RHEL 版本是 RHEL 至少是 10.2 或 9.8 版本。本文使用的是 RHEL 10.2。$cat/etc/redhat-release Red Hat Enterprise Linux release10.2(Coughlan)配置 RHEL 10 的 YUM Repo。$ subscription-manager repos--enablerhel-10-for-$(arch)-extensions-rpms安装 goose-redhat 软件包。goose-redhat 包中不但包括了 goose还包括 goose-proxy 和 goose-proxy-selinux。$ dnfinstall-ygoose-redhat为了 goose 的配置使生效启用一个新的 shell 会话。可选参照《RHEL - 在离线的 RHEL 10 中部署 Lightspeed》一文安装 RHEL Lightspeed 的 command-line-assistant 工具。说明goose 可以直接调用本机的 command-line-assistant也可调用多种大语言模型。配置 goose 的 provider运行命令配置 goose。$ goose configure在Share anonymous usage data to help improve goose?步骤选择合适的选项。在How would you like to set up your provider?步骤选择Manual Configuration (Choose a provider and enter credentials manually)使用 qwen 作为 provider可在另一个终端窗口先确认当前 qwen 模型可以访问。$URLYOUR_HOST$TOKENYOUR_ACCESS_TOKEN$curl-sk$URL/v1/completions\-HAuthorization: Bearer${TOKEN}\-HContent-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}在原有终端的What would you like to configure?步骤中选择Configure Providers。在Which model provider should we use?步骤选择OpenAI (GPT-4 and other OpenAI models, including OpenAI compatible ones)。在Would you like to set OPENAI_API_KEY? (optional)步骤选择 Yes。在Enter value for OPENAI_API_KEY后提供访问 qwen 模型的 OPENAI_API_KEY 内容。在Would you like to configure advanced settings?步骤选择 Yes。跳过Enter OPENAI_BASE_URL (optional, press Enter to skip)步骤。在Provider OpenAI requires OPENAI_HOST, please enter a value步骤提供访问 Qwen 模型的主机地址。在Provider OpenAI requires OPENAI_BASE_PATH, please enter a value步骤中接受默认值。跳过Enter OPENAI_ORGANIZATION (optional, press Enter to skip)步骤。跳过Enter OPENAI_PROJECT (optional, press Enter to skip)步骤。在Would you like to set OPENAI_CUSTOM_HEADERS? (optional)步骤选择 No。在Enter OPENAI_TIMEOUT (optional, press Enter to skip)步骤中接受默认值。如果前面提供的配置有效在Select a model步骤中可以显示出能访问的模型。可以选择一个可用的模型。最后 goose 会验证所有配置并将其保存到当前用户下的 ~/.config/goose/config.yaml 配置文件中。查看 config.yaml 配置文件中已包含以下内容。$cat~/.config/goose/config.yaml 。。。 OPENAI_HOST: https://litemaas.rhoai.rh-aiservices-bu.com OPENAI_BASE_PATH: v1/chat/completions OPENAI_TIMEOUT:600active_provider: openai providers: openai: enabled:truemodel: Qwen3.6-35B-A3B configured:true执行 goose 命令确认使用了前面选择的 Qwen3.6-35B-A3B 模型。$ goose注意可以用环境变量覆盖 config.yml 中的配置。$exportGOOSE_PROVIDERopenai $exportGOOSE_MODELQwen3.6-35B-A3B $exportOPENAI_HOSTYOUR_HOST$exportOPENAI_API_KEYYOUR_API_KEY$ goose session使用 command-line-assistant 作为 provider注意首先确保当前 RHEL 已安装了 command-line-assistant。另外在 goose configure 的 provider 列表中默认是没有 command-line-assistant 的只有在创建以下 custom provider 后才会出现创建过程系统会自动发现并创建也可手动按以下文件命和内容创建。确认手动或系统已自动在 ~/.config/goose/custom_providers 目录下创建了含有以下内容的 rhel_cla.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}执行配置命令。$ goose configure先进入Configure Providers然后在Which model provider should we use?步骤中选择RHEL command line assistant。其他步骤接受默认配置直到完成配置即可。执行命令确认使用的是RHEL command line assistant$ goose run-tWhat is the current OS version and kernel release?切换使用的模型在 goose 提示符后输入以下命令可以切换当前会话使用的 provider 模型。/model Qwen3.6-35B-A3B mode: Session model switched fromRHEL-command-line-assistanttoQwen3.6-35B-A3Bforproviderrhel_cla使用 goose单次模式每执行以下命令可完成一次 goose 调用。$ goose run-tWhat is the current OS version and kernel release?执行完会回到 bash。__(O)● new session · openai Qwen3.6-35B-A3B\____)20261023_4 · /root/.config L L goose is ready ──────────────────────────────────────── ▸ shell command:cat/etc/os-release2/dev/null|head-5;echo---;uname-rNAMERed Hat Enterprise LinuxVERSION10.2 (Coughlan)RELEASE_TYPEstableIDrhelID_LIKEcentos fedora---6.12.0-211.67.1.el10_2.x86_64 Heres the current system info: **OS:** Red Hat Enterprise Linux10.2(Coughlan)**Kernel release:**6.12.0-211.67.1.el10_2.x86_64交互模式运行 goose 命令进入交互模式界面停在 Enter to send · CtrlJ newline提示符处。$ 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 informationinyour input. Interactions may be used to improve Red Hats products or services. ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌0%0/128kEnter to send · CtrlJ newline在提示符后输入What is the current OS version and kernel release?命令然后查看返回结果。What is the current OS version and kernel release? ──────────────────────────────────────── ▸ shell command:cat/etc/redhat-releaseuname-rRed Hat Enterprise Linux release10.2(Coughlan)6.12.0-211.67.1.el10_2.x86_64 The current OS version is Red Hat Enterprise Linux release10.2(Coughlan)and the kernel release is6.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/7142302https://www.redhat.com/en/blog/supercharge-rhel-troubleshooting-agentic-ai-introducing-goosehttps://www.redhat.com/en/blog/smarter-troubleshooting-new-mcp-server-red-hat-enterprise-linux-now-developer-previewhttps://developers.redhat.com/articles/2026/10/08/manage-rhel-mcp-servers-and-red-hat-lightspeedhttps://github.com/rhel-lightspeed/goosehttps://goose-docs.ai/docs/quickstarthttps://www.youtube.com/watch?vik4q9_NMQPohttps://www.youtube.com/watch?vPz1CCvJdBSk