2016-09-13 8 views
0

は、私は次のChefレシピ(web.rb)を持っている:- シェフ

include_recipe 'apt::default' 
include_recipe 'awesome_customers_ubuntu::firewall' 
include_recipe 'awesome_customers_ubuntu::web_user' 
include_recipe 'awesome_customers_ubuntu::web' 

attributes/default.rb

# Install Apache and start the service. 
httpd_service 'customers' do 
    mpm 'prefork' 
    action [:create, :start] 
end 

# Add the site configuration. 
httpd_config 'customers' do 
    instance 'customers' 
    source 'customers.conf.erb' 
    notifies :restart, 'httpd_service[customers]' 
end 

# Create the document root directory. 
directory node['awesome_customers_ubuntu']['document_root'] do 
    recursive true 
end 

# Write the home page. 
file "#{node['awesome_customers_ubuntu']['document_root']}/index.html" do 
    content '<html>This is a placeholder</html>' 
    mode '0644' 
    owner node['awesome_customers_ubuntu']['user'] 
    group node['awesome_customers_ubuntu']['group'] 
end 

default.rbレシピは次のようになります

default['firewall']['allow_ssh'] = true 
default['awesome_customers_ubuntu']['open_ports'] = 80 

default['awesome_customers_ubuntu']['user'] = 'web_admin' 
default['awesome_customers_ubuntu']['group'] = 'web_admin' 
default['awesome_customers_ubuntu']['document_root'] = '/var/www/customers/public_html' 

kitchen convergeを実行すると、次のエラーが表示されます:

Recipe: awesome_customers_ubuntu::web 
     * httpd_service_debian_sysvinit[customers] action create[2016-09-13T02:40:18+00:00] WARN: Default value nil is invalid for property version of resource . Possible fixes: 1. Remove 'default: nil' if nil means 'undefined'. 2. Set a valid default value if there is a reasonable one. 3. Allow nil as a valid value of your property (for example, 'property :version, [ String, nil ], default: nil'). Error: Property version must be one of: String! You passed nil. at /tmp/kitchen/cache/cookbooks/httpd/libraries/helpers.rb:101:in `default_package_name' 
     [2016-09-13T02:40:18+00:00] WARN: Default value nil is invalid for property package_name of resource . Possible fixes: 1. Remove 'default: nil' if nil means 'undefined'. 2. Set a valid default value if there is a reasonable one. 3. Allow nil as a valid value of your property (for example, 'property :package_name, [ String, nil ], default: nil'). Error: Property package_name must be one of: String! You passed nil. at /tmp/kitchen/cache/cookbooks/httpd/libraries/httpd_service_debian.rb:8:in `block in <class:HttpdServiceDebian>' 


      ================================================================================ 
      Error executing action `create` on resource 'httpd_service_debian_sysvinit[customers]' 
      ================================================================================ 

      ArgumentError 
      ------------- 
      You must supply a name when declaring a package resource 

      Cookbook Trace: 
      --------------- 
      /tmp/kitchen/cache/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/dsl/declare_resource.rb:302:in `build_resource' 
      /tmp/kitchen/cache/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/dsl/declare_resource.rb:259:in `declare_resource' 
      /tmp/kitchen/cache/cookbooks/httpd/libraries/httpd_service_debian.rb:8:in `block in <class:HttpdServiceDebian>' 
      /tmp/kitchen/cache/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider.rb:132:in `instance_eval' 
      /tmp/kitchen/cache/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider.rb:132:in `compile_and_converge_action' 
      /tmp/kitchen/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:78:in `run_action' 
      /tmp/kitchen/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:106:in `block (2 levels) in converge' 
      /tmp/kitchen/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:106:in `each' 
      /tmp/kitchen/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:106:in `block in converge' 
      /tmp/kitchen/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:105:in `converge' 

      Resource Declaration: 
      --------------------- 
      # In /tmp/kitchen/cache/cookbooks/awesome_customers_ubuntu/recipes/web.rb 

      8: httpd_service "customers" do 
      9:  mpm "prefork" 
      10:  action [:create, :start] 
      11: end 
      12: 

      Compiled Resource: 
      ------------------ 
      # Declared in /tmp/kitchen/cache/cookbooks/awesome_customers_ubuntu/recipes/web.rb:8:in `from_file' 

      httpd_service_debian_sysvinit("customers") do 
      action [:create, :start] 
      retries 0 
      retry_delay 2 
      default_guard_interpreter :default 
      declared_type :httpd_service 
      cookbook_name "awesome_customers_ubuntu" 
      recipe_name "web" 
      mpm "prefork" 
      end 

      Platform: 
      --------- 
      x86_64-linux 

     Recipe: firewall::default 
     * firewall[default] action restart 
      (skipped due to only_if) 
      (skipped due to only_if) 
     (skipped due to only_if) 
     * file[/etc/default/ufw-chef.rules] action create (up to date) 
     (up to date) 

     Running handlers: 
     [2016-09-13T02:40:18+00:00] ERROR: Running exception handlers 
     Running handlers complete 
     [2016-09-13T02:40:18+00:00] ERROR: Exception handlers complete 
     Chef Client failed. 3 resources updated in 06 seconds 
     [2016-09-13T02:40:18+00:00] FATAL: Stacktrace dumped to /tmp/kitchen/cache/chef-stacktrace.out 
     [2016-09-13T02:40:18+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report 
     [2016-09-13T02:40:18+00:00] ERROR: httpd_service_debian_sysvinit[customers] (awesome_customers_ubuntu::web line 8) had an error: ArgumentError: You must supply a name when declaring a package resource 
     [2016-09-13T02:40:19+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1) 

この問題を解決するにはどうすればよいですか?

+0

これはどのOSですか? – coderanger

+0

@コーデンジャーUbuntu 16.04 – cybertextron

+0

あなたの設定では何か非常に厄介ですが、16.04で 'httpd_service_debian_systemd'の実装を使用する必要があります。 – coderanger

答えて

1

https://github.com/chef-cookbooks/httpd/blob/master/libraries/httpd_service_debian.rb#L8で、package_nameはnilと思われます。レイジーあなたがあることを明示的にリソースを宣言することによって、これを回避することができますhttps://github.com/chef-cookbooks/httpd/blob/master/libraries/info_service_packages.rb#L37

からパッケージ名をロードに依存しているhttps://github.com/chef-cookbooks/httpd/blob/master/libraries/httpd_service.rb#L23へのリード線を介してこれをトレース

httpd_service 'customers' do 
    mpm 'prefork' 
    package_name 'apache2' 
    action [:create, :start] 
end 

けれども、あなたは本当に「shouldn必要はありません!おそらくバグを報告しますか?