I am trying to install java using chef-solo. The problem is to set the variables JAVA_HOMEand PATHfile /etc/profile. I tried to use the resource 'file'provided by the chef. here is my code:
java_home = "export JAVA_HOME=/usr/lib/java/jdk1.7.0_05"
path = "export PATH=$PATH:/usr/lib/java/jdk1.7.0_05/bin"
execute "make_dir" do
cwd "/usr/lib/"
user "root"
command "mkdir java"
end
execute "copy" do
cwd "/usr/lib/java"
user "root"
command "cp -r /home/user/Downloads/jdk1* /usr/lib/java"
end
file "/etc/profile" do
owner "root"
group "root"
action :touch
content JAVA_HOME
content PATH
end
but the problem in the command contentcancels the entire contents of the file, is there a way to UPDATE the file when using chef-solo resources. Thank!
UPDATE: I found the code from chef-recipe, but I'm not sure what it does exactly, the code ...
ruby_block "set-env-java-home" do
block do
ENV["JAVA_HOME"] = java_home
end
end
Does the JAVA_HOME variable set only for this instance or permanently? Can anyone help?
itsme source
share