我正在尝试使用chef solo为我的项目设置newrelic infra chef食谱遵循文档中列出的指导原则:Configure New Relic Infrastructure using Chef
目标:
在ubuntu框中启动newrelic infra服务。
所述步骤如下:
新的遗迹食谱可以从公共厨师超市买到。
要使用chef安装和配置new relic基础设施,请执行以下操作:
在您自己的chef metadata.rb或berksfile-done中添加newrelic infra依赖项
元数据.rb
depends 'newrelic-infra'
设置new relic许可证密钥属性。例如,在recipes/default.rb中添加以下内容:-完成
newrelic infra/attributes/default.rb
# New Relic infrastructure agent configuration options
default['newrelic_infra']['config'].tap do |conf|
# Account license key
conf['license_key'] = 'added my license key here'
通过使用include_recipe'new relic infra::default'或将配方添加到运行列表中,包括默认的newrelic配方。-完成
New Relic Infra Cookbook的依赖项是Poise Service和Poise Archive v1.5.0:
所以我把这三本烹饪书都加到了运行列表中流浪者档案看起来是这样的:
Vagrant.configure('2') do |config|
config.vm.box = 'bento/ubuntu-18.04'
...
...
config.vm.provision 'shell', inline: <<~SHELL
wget -q -O /tmp/chefdk.deb https://packages.chef.io/files/stable/chefdk/3.2.30/ubuntu/18.04/chefdk_3.2.30-1_amd64.deb
apt-get -q install -y /tmp/chefdk.deb
mkdir /tmp/cookbooks
...
rsync -av /vagrant/infrastructure-agent-chef/ /tmp/cookbooks/newrelic-infra/
git clone https://github.com/poise/poise-service.git /tmp/cookbooks/poise-service
cd /tmp/cookbooks/poise-service && git checkout v1.5.0
git clone https://github.com/poise/poise-archive.git /tmp/cookbooks/poise-archive
cd /tmp/cookbooks/poise-archive && git checkout v1.5.0
echo '{"run_list":["recipe[newrelic-infra]", "recipe[poise-service]", "recipe[poise-archive]"]}' > /tmp/runlist.json
chef-solo -j /tmp/runlist.json --recipe-url /tmp/random.tar.gz
SHELL
end
最后,当我使用vagrant up运行newrelic infra服务时,看到以下错误:
default: Starting Chef Client, version 14.4.56 default: resolving cookbooks for run list: ["newrelic-infra", "poise-service", "poise-archive"] default: Synchronizing Cookbooks: default: - newrelic-infra (0.11.0) default: - poise-service (0.0.0) default: default: - poise-archive (0.0.0) default: Installing Cookbook Gems: default: Compiling Cookbooks... default: default: ================================================================================ default: Recipe Compile Error in /etc/chef/local-mode-cache/cache/cookbooks/newrelic-infra/recipes/default.rb default: ================================================================================ default: default: default: NoMethodError default: ------------- default: undefined method poise_service_user' for cookbook: newrelic-infra, recipe: agent_linux :Chef::Recipe
default:
default:
default: Cookbook Trace:
default: ---------------
default: /etc/chef/local-mode-cache/cache/cookbooks/newrelic-infra/recipes/agent_linux.rb:17:in from_file' default: default: /etc/chef/local-mode-cache/cache/cookbooks/newrelic-infra/recipes/default.rb:11:in from_file'
default:
default: Relevant File Content:
default: ----------------------
default: /etc/chef/local-mode-cache/cache/cookbooks/newrelic-infra/recipes/agent_linux.rb:
default:
default: 10: #
default: 11: node.default['newrelic_infra']['agent']['flags']['config'] = ::File.join(
default: 12: node['newrelic_infra']['agent']['directory']['path'],
default: 13: node['newrelic_infra']['agent']['config']['file']
default: 14: )
default: 15:
default: 16: # Setup a service account
default: 17>> poise_service_user node['newrelic_infra']['user']['name'] do
default: 18: group node['newrelic_infra']['group']['name']
default: 19: only_if { node['newrelic_infra']['features']['manage_service_account'] }
default: 20: end
default: 21:
default: 22: # Based on the Ohai attribute platform_family either an APT or YUM repository
default: 23: # will be created. The respective Chef resources are built using metaprogramming,
default: 24: # so that the configuration can be extended via attributes without having to
default: 25: # release a new version of the cookbook. Attributes that cannot be passed to the resource
default: 26: # are logged out as warnings in order to prevent potential failes from typos,
default:
default: System Info:
default: ------------
default: chef_version=14.4.56
default: platform=ubuntu
default: platform_version=18.04
default: ruby=ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]
default: program_name=/usr/bin/chef-solo
default: executable=/opt/chefdk/bin/chef-solo
default:
default:
default: Running handlers:`
我花了几个小时研究github中的菜谱源代码,但还没有运气,有人有什么想法或故障排除技巧吗?我对厨师或红宝石还不太熟悉,所以我非常感谢你的建议。
谢谢!
有用链接:
https://github.com/newrelic/infrastructure-agent-chef
https://github.com/poise/poise-service
https://github.com/poise/poise-archive
最佳答案
我在github中提出了一个问题,看起来poise服务的菜谱已经不再维护了,几小时前店主将其存档了。
关于ruby - 菜谱的未定义方法“poise_service_user”:newrelic-infra,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/57699274/