You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

New Relic基础设施Agent安装报错:缺少NewRelic密钥求助

解决New Relic基础设施Agent Chef Cookbook安装时的密钥缺失问题

从你提供的报错信息和Recipe代码来看,核心问题是在newrelic::infrastructure_agent Recipe执行时,node['newrelic']['license']属性还没被正确设置,导致Cookbook的校验逻辑触发了RuntimeError: The NewRelic key is required错误。

问题根源分析

你当前的Recipe执行顺序出了问题:

  1. 先引入了newrelic::infrastructure_agent Recipe
  2. 之后才赋值node.normal['newrelic']['license']属性

Chef是按Recipe的代码顺序逐行执行的,当newrelic::infrastructure_agent里的newrelic_agent_infrastructure 'Install'资源运行时,你的密钥还没被赋值,自然会触发校验失败。

修复方案

调整代码顺序,先设置密钥属性,再引入New Relic的Recipe:

# Cookbook:: third-party-newrelic
# Recipe:: infraestructure-agent
# Copyright:: 2018, The Authors, All Rights Reserved.

include_recipe 'base::databag'

# 优先加载并设置New Relic密钥属性
newrelic = decrypt_databag('newrelic')
node.normal['newrelic']['license'] = newrelic['license_key']

# 再引入New Relic的基础设施Agent Recipe
include_recipe 'newrelic::infrastructure_agent'

额外排查建议

如果调整顺序后仍有问题,可以做以下验证:

  • 确认decrypt_databag('newrelic')确实能返回包含有效license_key的数据
  • 在引入New Relic Recipe前,临时添加日志输出验证属性是否生效:
    Chef::Log.info("当前New Relic密钥值: #{node['newrelic']['license']}")
    
  • 如果你用node.default_unless设置密钥,检查是否有更高优先级的属性(比如环境、角色属性)覆盖了这个值

内容的提问来源于stack exchange,提问作者Daniel

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 08:53:00