在资源“模板[/etc/awslogs//cwlogs.cfg]”上出错“创建”

时间:2019-04-30 10:45:27

标签: chef amazon-cloudwatch cookbook amazon-cloudwatchlogs

我正在尝试执行厨师操作,但标题中始终出现错误。日志输出如下;

Error executing action `create` on resource 'template[/tmp/cwlogs.cfg]'
================================================================================

Chef::Mixin::Template::TemplateError
------------------------------------
undefined method `[]' for nil:NilClass

Resource Declaration:
---------------------
# In /var/chef/runs/b2cd9efb-b9d2-4c1a-b582-5ebfbe933bdd/local-mode-cache/cache/cookbooks/phpapp/recipes/setup.rb

45: template "/tmp/cwlogs.cfg" do
46:   source "cwlogs.cfg.erb"
47:   owner "root"
48:   group "root"
49:   mode 0644
50: end
51: # cloudwatch packages

Compiled Resource:
------------------
# Declared in /var/chef/runs/b2cd9efb-b9d2-4c1a-b582-5ebfbe933bdd/local-mode-cache/cache/cookbooks/phpapp/recipes/setup.rb:45:in `from_file'

template("/tmp/cwlogs.cfg") do
action [:create]
retries 0
retry_delay 2
default_guard_interpreter :default
source "cwlogs.cfg.erb"
declared_type :template
cookbook_name "phpapp"
recipe_name "setup"
mode 420
owner "root"
group "root"
path "/tmp/cwlogs.cfg"
end

Template Context:
-----------------
on line #30
28: #
29: 
30: [<%= node[:opsworks][:stack][:name] %>]
31: datetime_format = [%Y-%m-%d %H:%M:%S]
32: log_group_name = <%= node[:opsworks][:stack][:name].gsub(' ','_') %>

我尝试查看类似问题的现有答案,但他们都发现了似乎无法反映我的情况的不同问题。

有人有什么建议吗?

1 个答案:

答案 0 :(得分:0)

您的模板似乎包含导致此问题的嵌入式代码... 通过查看您的摘要,node[:opsworks][:stack][:name]的价值是什么?