Ubuntu Can';使用Chef重启防火墙
我正在使用Ubuntu Can';使用Chef重启防火墙,ubuntu,chef-infra,firewall,ufw,Ubuntu,Chef Infra,Firewall,Ufw,我正在使用Chef为Ubuntu14.04的防火墙编写一本食谱 伯克斯菲尔 网站cookbooks/ufw/recipes/default.rb 网站cookbooks/ufw/metadata.rb nodes/myserver.json myserver最终会出现如下错误: Recipe: firewall::default * firewall[default] action restart ==========================================
Chef
为Ubuntu14.04的防火墙编写一本食谱
伯克斯菲尔
网站cookbooks/ufw/recipes/default.rb
网站cookbooks/ufw/metadata.rb
nodes/myserver.json
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
Recipe:firewall::default
*防火墙[默认]操作重新启动
================================================================================
在资源防火墙[默认]上执行操作“重新启动”时出错
================================================================================
命名者
-------------
未定义的方法“include?”用于:create:Symbol
食谱跟踪:
---------------
/home/ironsand/chef solo/cookbooks-3/firewall/libraries/provider_firewall_ufw.rb:67:in'block(2层)in'
/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'
资源声明:
---------------------
#在/home/ironsand/chef solo/cookbooks-3/firewall/recipes/default.rb中
22:防火墙“默认”do
23:启用ipv6_的节点['firewall']['ipv6_enabled']
24:操作:安装
25:完
26:
汇编资源:
------------------
#在/home/ironsand/chef solo/cookbooks-3/firewall/recipes/default.rb:22:in‘from_file’中声明
防火墙(“默认”)怎么办
操作[:安装]
更新真实
重试0次
重试\u延迟2
默认\u保护\u解释器:默认值
声明的类型:防火墙
食谱名称:防火墙
配方名称“默认”
已启用ipv6\u为true
启用真
规则{“ufw”=>{}
结束
我做错了什么?如何修复它?看起来像是
防火墙中的一个bug。应该将动作强制到数组以确保安全。如果您在防火墙上设置了操作[:创建]
\u rule`resource,它可能会工作。也许您应该从Chef supermarket安装烹饪书。请参阅如何在此处安装。您需要保证metadata.rb
和Policyfile.rb
的一致性。如果您没有得到任何更新,请删除Policyfile.lock.json
。在你的食谱中添加包括\u recipe'firewall::default'
。什么版本的厨师?您可以看到它显示在chef-client
输出的顶部。此外,您不应该再使用api.berkself.com
。它与此问题无关,但对您的berks源代码使用supermarket.chef.io
。@coderanger我使用的是12.3.0
,并更新为12.8.1
,但错误保持不变。我设置了操作[:创建]
,但错误保持不变。我将对
ufw`使用execute方法,但这不是一个好方法。
firewall 'ufw'
firewall_rule 'http' do
port 80
end
firewall_rule 'https' do
port 443
end
depends 'firewall'
{
"run_list": [
"firewall",
"ufw"
]
}
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