简体   繁体   English

使用数据包在资源“ newrelic_agent_infrastructure [安装]”上执行操作“安装”时出错

[英]Error executing action `install` on resource 'newrelic_agent_infrastructure[Install]' using data bag

We're trying to install New Relic infrastructure agent using a third party cookbook. 我们正在尝试使用第三方食谱来安装New Relic基础设施代理。 But we've got an error: 但是我们有一个错误:
Error executing action install on resource 'newrelic_agent_infrastructure[Install]' 在资源“ newrelic_agent_infrastructure [安装]”上执行操作install时出错

Our Recipe: 我们的食谱:

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

include_recipe 'base::databag'
include_recipe 'newrelic::infrastructure_agent'
# Default Variables
newrelic = decrypt_databag('newrelic')

node.normal['newrelic']['license'] = newrelic['license_key']

Log Error: 记录错误:

Recipe: newrelic::infrastructure_agent
  * newrelic_agent_infrastructure[Install] action install

    ================================================================================
    Error executing action `install` on resource 'newrelic_agent_infrastructure[Install]'
    ================================================================================

    RuntimeError
    ------------
    The NewRelic key is required.

    Cookbook Trace:
    ---------------
    /var/chef/cache/cookbooks/newrelic/libraries/helpers.rb:15:in `check_license'
    /var/chef/cache/cookbooks/newrelic/providers/agent_infrastructure.rb:18:in `block in class_from_file'

    Resource Declaration:
    ---------------------
    # In /var/chef/cache/cookbooks/newrelic/recipes/infrastructure_agent.rb

      8: newrelic_agent_infrastructure 'Install'

    Compiled Resource:
    ------------------
    # Declared in /var/chef/cache/cookbooks/newrelic/recipes/infrastructure_agent.rb:8:in `from_file'

    newrelic_agent_infrastructure("Install") do
      action [:install]
      default_guard_interpreter :default
      declared_type :newrelic_agent_infrastructure
      cookbook_name "newrelic"
      recipe_name "infrastructure_agent"
    end

    System Info:
    ------------
    chef_version=13.8.5
    platform=ubuntu
    platform_version=16.04
    ruby=ruby 2.4.3p205 (2017-12-14 revision 61247) [x86_64-linux]
    program_name=chef-client worker: ppid=101819;start=19:52:27;
    executable=/opt/chef/bin/chef-client


Running handlers:
[2018-05-10T19:52:34+00:00] ERROR: Running exception handlers
Running handlers complete
[2018-05-10T19:52:34+00:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated in 07 seconds
[2018-05-10T19:52:34+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2018-05-10T19:52:34+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2018-05-10T19:52:34+00:00] ERROR: newrelic_agent_infrastructure[Install] (newrelic::infrastructure_agent line 8) had an error: RuntimeError: The NewRelic key is required.
[2018-05-10T19:52:34+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

Even though using the follow line instead of a data bag: 即使使用以下行代替数据包:

node.default_unless['newrelic']['license'] = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" node.default_unless ['newrelic'] ['license'] =“ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx”

We've tried many alternatives for this command, but it wasn't fertile. 我们已经为该命令尝试了许多替代方法,但是它并不肥沃。

Thanks in Advance. 提前致谢。

是相关的代码,它应该可以工作,但是您可以尝试:

node.override['newrelic']['application_monitoring']['license'] = 'asdf'

by the issue: https://github.com/djoos-cookbooks/newrelic/issues/345 通过问题: https : //github.com/djoos-cookbooks/newrelic/issues/345

Ok. 好。 We manage to solve this problem by changing this line in the followed files: ../resources/agent_infrastructure.rb ../resources/agent_php.rb 我们设法通过在以下文件中更改此行来解决此问题:../resources/agent_infrastructure.rb ../resources/agent_php.rb

From: 从:

attribute :license, :kind_of => String, :default => NewRelic.application_monitoring_license(node) 属性:license,:kind_of =>字符串,:default => NewRelic.application_monitoring_license(节点)

To: 至:

attribute :license, :kind_of => String, :default => lazy { NewRelic.application_monitoring_license(node) } 属性:license,:kind_of =>字符串,:default => lazy {NewRelic.application_monitoring_license(node)}

Inside the recipe 里面的食谱

node.default['newrelic']['license'] = newrelic['license_key'] node.default ['newrelic'] ['license'] = newrelic ['license_key']

Calling our data bag with this structure: 用以下结构调用我们的数据包:

id: newrelic id:newrelic

license_key:xxxxxxxxxxxxxxxxxxxxx 许可密钥:xxxxxxxxxxxxxxxxxxxxx

Thanks for your help. 谢谢你的帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM