ruby on rails - Supplying a name when declaring a package resource - Chef -
i have following chef
recipe (web.rb
):
# install apache , start service. httpd_service 'customers' mpm 'prefork' action [:create, :start] end # add site configuration. httpd_config 'customers' instance 'customers' source 'customers.conf.erb' notifies :restart, 'httpd_service[customers]' end # create document root directory. directory node['awesome_customers_ubuntu']['document_root'] recursive true end # write home page. file "#{node['awesome_customers_ubuntu']['document_root']}/index.html" content '<html>this placeholder</html>' mode '0644' owner node['awesome_customers_ubuntu']['user'] group node['awesome_customers_ubuntu']['group'] end
my default.rb
recipe looks like:
include_recipe 'apt::default' include_recipe 'awesome_customers_ubuntu::firewall' include_recipe 'awesome_customers_ubuntu::web_user' include_recipe 'awesome_customers_ubuntu::web'
and attributes/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'
when execute kitchen converge
i'm getting following error:
recipe: awesome_customers_ubuntu::web * httpd_service_debian_sysvinit[customers] action create[2016-09-13t02:40:18+00:00] warn: default value nil invalid property version of resource . possible fixes: 1. remove 'default: nil' if nil means 'undefined'. 2. set valid default value if there reasonable one. 3. allow nil valid value of property (for example, 'property :version, [ string, nil ], default: nil'). error: property version must 1 of: string! passed nil. @ /tmp/kitchen/cache/cookbooks/httpd/libraries/helpers.rb:101:in `default_package_name' [2016-09-13t02:40:18+00:00] warn: default value nil invalid property package_name of resource . possible fixes: 1. remove 'default: nil' if nil means 'undefined'. 2. set valid default value if there reasonable one. 3. allow nil valid value of property (for example, 'property :package_name, [ string, nil ], default: nil'). error: property package_name must 1 of: string! passed nil. @ /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 ------------- must supply name when declaring 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" 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") 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 only_if) (skipped due only_if) (skipped due only_if) * file[/etc/default/ufw-chef.rules] action create (up date) (up 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 /tmp/kitchen/cache/chef-stacktrace.out [2016-09-13t02:40:18+00:00] fatal: please provide contents of stacktrace.out file if file bug report [2016-09-13t02:40:18+00:00] error: httpd_service_debian_sysvinit[customers] (awesome_customers_ubuntu::web line 8) had error: argumenterror: must supply name when declaring package resource [2016-09-13t02:40:19+00:00] fatal: chef::exceptions::childconvergeerror: chef run process exited unsuccessfully (exit code 1)
how can fix problem?
it seems like, @ https://github.com/chef-cookbooks/httpd/blob/master/libraries/httpd_service_debian.rb#l8 , package_name nil.
tracing through leads https://github.com/chef-cookbooks/httpd/blob/master/libraries/httpd_service.rb#l23 relies on lazily loading package name https://github.com/chef-cookbooks/httpd/blob/master/libraries/info_service_packages.rb#l37
you can around declaring resource explicitly be:
httpd_service 'customers' mpm 'prefork' package_name 'apache2' action [:create, :start] end
although, shouldn't need to! perhaps file bug?
Comments
Post a Comment