I have the following (simplified) recipe called java, to install Java of course.
File recipes/default.rb
include_recipe "install_java"
File recipes/install_java.rb
# Install RPM from yum repo via yum_install library function
yum_install("jdk1.7.0_51")
# List the directories in /usr/java
jdk_dir = `ls -ld /usr/java/jdk1.* | sort | tail -1`
if jdk_dir.empty?
raise "Missing JDK installation"
end
When I run the recipe by "chef-client -o recipe[java]"
Synchronizing Cookbooks:
- java
Compiling Cookbooks...
ls: /usr/java/jdk1.*: No such file or directory
=========================================================================== Recipe Compile Error in /var/chef/cache/cookbooks/java/recipes/default.rb ===========================================================================
RuntimeError
------------
Missing JDK installation
It seems like the yum_install() function is NOT being called. However, if I modify the install_java.rb recipe to just have
# Install RPM from yum repo via yum_install library function
yum_install("jdk1.7.0_51")
it works.
Why is this?
See Question&Answers more detail:os