【问题标题】:Error executing action `install` on resource 'newrelic_agent_infrastructure[Install]' using data bag使用数据包对资源“newrelic_agent_infrastructure[Install]”执行操作“安装”时出错
【发布时间】:2018-05-18 21:05:11
【问题描述】:

我们正在尝试使用第三方说明书安装 New Relic 基础架构代理。但是我们有一个错误:
在资源“newrelic_agent_infrastructure[Install]”上执行操作 install 时出错

我们的食谱:

#
# 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']

日志错误:

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)

即使使用后续行而不是数据包:

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

我们已经为此命令尝试了许多替代方法,但效果不佳。

提前致谢。

【问题讨论】:

    标签: linux chef-infra chef-recipe databags


    【解决方案1】:

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

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

    【讨论】:

    • 您确定要在某个位置设置属性,然后才能使用它?
    • 它没有 lazy{} 包装器,因此在文件编译时进行评估。您必须通过角色或环境或其他静态设置 attr。
    • 非常感谢@coderanger,我看到您为 djoos 打开了一个问题以更正包装器。 “。您必须通过角色或环境或其他静态设置属性。”我们想了想,但是我们如何才能在角色中插入数据包呢?提前致谢。
    • 很遗憾,您目前无法使用数据包。
    【解决方案2】:

    按问题: https://github.com/djoos-cookbooks/newrelic/issues/345

    好的。我们设法通过更改以下文件中的这一行来解决这个问题: ../resources/agent_infrastructure.rb ../resources/agent_php.rb

    发件人:

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

    收件人:

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

    食谱内

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

    用这个结构调用我们的数据包:

    id: 新遗物

    license_key:xxxxxxxxxxxxxxxxxxxxx

    感谢您的帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-25
      • 1970-01-01
      • 1970-01-01
      • 2014-06-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多