0

我正在使用Chef.

伯克斯文件

source "https://api.berkshelf.com"

cookbook 'firewall'

网站食谱/ufw/recipes/default.rb

firewall 'ufw'

firewall_rule 'http' do
  port 80
end

firewall_rule 'https' do
  port 443
end

网站食谱/ufw/metadata.rb

depends 'firewall'

节点/myserver.json

{
    "run_list": [
        "firewall",
        "ufw"
    ]
}

knife solo cook myserver最终出现如下错误:

Recipe: firewall::default
  * firewall[default] action restart

    ================================================================================
    Error executing action `restart` on resource 'firewall[default]'
    ================================================================================

    NoMethodError
    -------------
    undefined method `include?' for :create:Symbol

    Cookbook Trace:
    ---------------
    /home/ironsand/chef-solo/cookbooks-3/firewall/libraries/provider_firewall_ufw.rb:67:in `block (2 levels) in <class:FirewallUfw>'
    /home/ironsand/chef-solo/cookbooks-3/firewall/libraries/provider_firewall_ufw.rb:66:in `each'
    /home/ironsand/chef-solo/cookbooks-3/firewall/libraries/provider_firewall_ufw.rb:66:in `block in <class:FirewallUfw>'

    Resource Declaration:
    ---------------------
    # In /home/ironsand/chef-solo/cookbooks-3/firewall/recipes/default.rb

     22: firewall 'default' do
     23:   ipv6_enabled node['firewall']['ipv6_enabled']
     24:   action :install
     25: end
     26:

    Compiled Resource:
    ------------------
    # Declared in /home/ironsand/chef-solo/cookbooks-3/firewall/recipes/default.rb:22:in `from_file'

    firewall("default") do
      action [:install]
      updated true
      retries 0
      retry_delay 2
      default_guard_interpreter :default
      declared_type :firewall
      cookbook_name :firewall
      recipe_name "default"
      ipv6_enabled true
      enabled true
      rules {"ufw"=>{}}
    end

我做错了什么?我该如何解决?

4

2 回答 2

0

看起来像firewall食谱中的错误。https://github.com/chef-cookbooks/firewall/blob/master/libraries/provider_firewall_ufw.rb#L67应该将操作转换为安全的数组。如果您action [:create]在 firewall_rule 资源上进行设置,它可能会起作用。

于 2016-04-12T23:13:33.953 回答
0

也许你应该从 Chef 超市安装食谱。在此处查看如何安装https://blog.chef.io/using-chef-supermarket-a-guided-tour。您需要保证 和 的连贯metadata.rbPolicyfile.rbPolicyfile.lock.json如果没有得到任何更新,请删除。也添加include_recipe 'firewall::default' 到您的食谱中。

于 2020-12-10T15:49:03.347 回答