Cookbook not working


#1

case node[‘platform_family’]
when ‘rhel’
include_recipe ‘bigfix::Rhel-bigfix’
when ‘ubuntu’
include_recipe ‘bigfix::Ubuntu-bigfix’
else
puts “Skipping Installation - Cookbook doesn’t support platform_family”
end

bigfix is my cookbook name
Rhel-bigfix & Ubuntu-bigfix is my recipes

when i deploy this Rhel-bigfix is working fine but Ubuntu is not working
when deploy in ubuntu i guess its skipping installation
please advice any platform_family (when ‘ubuntu’) need any correction
iam using Ubuntu 16.04.3 LTS


#2

You can check the platform_family of a node by running ohai platform_family on the node in question.


#3

Where is your second “else” and “end” that would encapsulate your “ubuntu” statements, if you’re not running RHEL ? ? “when” statements are not case statements, they don’t just automatically fall through to the next statement.


#4

root@camdevubnd:/opt/chef/bin# ls
chef-apply chef-client chef-shell chef-solo knife ohai
root@camdevubnd:/opt/chef/bin# cat ohai
#!/opt/chef/embedded/bin/ruby --disable-gems
#–APP_BUNDLER_BINSTUB_FORMAT_VERSION=1–
ENV[“GEM_HOME”] = ENV[“GEM_PATH”] = nil unless ENV[“APPBUNDLER_ALLOW_RVM”] == “true”
require “rubygems”
::Gem.clear_paths

gem “chef-config”, “= 12.17.44”
gem “addressable”, “= 2.4.0”
gem “fuzzyurl”, “= 0.9.0”
gem “mixlib-config”, “= 2.2.4”
gem “mixlib-shellout”, “= 2.2.7”
gem “ffi”, “= 1.9.14”
gem “ffi-yajl”, “= 2.3.0”
gem “libyajl2”, “= 1.2.0”
gem “ipaddress”, “= 0.8.3”
gem “mixlib-cli”, “= 1.7.0”
gem “mixlib-log”, “= 1.7.1”
gem “plist”, “= 3.2.0”
gem “systemu”, “= 2.6.5”
gem “wmi-lite”, “= 1.0.0”
gem “ohai”, “= 8.22.0”

spec = Gem::Specification.find_by_name(“ohai”, “= 8.22.0”)
bin_file = spec.bin_file(“ohai”)


#5

Run the ohai command I gave you.


#6

root@camdevubnd:/opt/chef/bin# ohai platform_family
[
“debian”
]
root@camdevubnd:/opt/chef/bin#

Very Thanks


#7

Gahhh. Sorry, I misread your software, you are correctly using the case statement.

One of the most useful things to do with error statements is to have them actually publish the information that generated the error. In this case where you publish “Skipping Installation - Cookbook doesn’t support platform_family”, I urge you to actually report the “node[‘platform_family’]” that is not being supported. Such debug reporting will be your friend for the future.


#8

@venkatraj Please try the following snippet, it should work.

case node[‘platform_family’]
when ‘rhel’
include_recipe ‘bigfix::Rhel-bigfix’
when ‘debian’
include_recipe ‘bigfix::Ubuntu-bigfix’
else
puts “Skipping Installation - Cookbook doesn’t support platform_family”
end