【发布时间】:2015-08-08 04:07:32
【问题描述】:
我正在尝试编写自定义资源和提供程序来配置 splunk 文件。
以下是资源/提供者/配方的代码:
splunk/recipes/default.rb
Chef::Log.info "Creating directory /opt/splunkforwarder/etc/apps/myapps/"
directory "/opt/splunkforwarder/etc/apps/myapps/" do
action :create
end
splunk_monitor "/opt/splunkforwarder/etc/apps/myapps/apache.conf" do
monitoring_path "/logs/logsw0/access_log"
source_type "combined_log"
whitelist "access"
index "web"
ignore_older_than "15d"
file_path "/opt/splunkforwarder/etc/apps/myapps/apache.conf"
action :create
end
splunk/resources/monitor.rb
provides :monitor
actions :create
default_action :create
attribute :name, :kind_of => String, :required => true
attribute :monitoring_path, :kind_of => String, :required => true
attribute source_type, :kind_of => String, :required => true
attribute :whitelist, :kind_of => String , :required => true
attribute :index, :kind_of => String, :required => true
attribute :ignore_older_than, :kind_of => String, :required => true
attr_accessor :name, :monitoring_path , ource_type, :whitelist , :index, :ignore_older_than
splunk/providers/monitor.rb
action :create do
template new_resource.name do
source 'input.conf.erb'
owner 'root'
group 'root'
mode 0644
variables ( {
"monitoring_path" => new_resource.monitoring_path,
"whitelist" => new_resource.whitelist,
"index" => new_resource.index,
"source_type" => new_resource.source_type,
"ignore_older_than" => new_resource.ignore_older_than
} )
end
new_resource.updated_by_last_action(true)
end
在单独运行 chef 时会抛出给定的错误。厨师独奏版是11.12.8。
错误
========================================================================
Recipe Compile Error in /home/rjain/cookbooks/splunk/recipes/default.rb
============================================================================
ArgumentError
-------------
wrong number of arguments (1 for 0)
Cookbook Trace:
---------------
/home/rjain/cookbooks/splunk/recipes/default.rb:7:in `block in from_file'
/home/rjain/cookbooks/splunk/recipes/default.rb:6:in `from_file'
我试图通过比较apt 提供者/资源在我的代码中解决这个问题,但仍然没有运气。 任何人都可以提出代码中的问题。
提前致谢。
【问题讨论】:
标签: ruby chef-infra chef-recipe chef-solo