Saturday, 15 January 2011

Giving different installation path for java in chef recipe -



Giving different installation path for java in chef recipe -

this question has reply here:

run sql files chef 1 reply

i trying installing java help of below code default installs in /usr/java/ directory.. want installed on separate directory illustration /u01/app.

recipe class="lang-rb prettyprint-override"># remove old environment notify new environment created ruby_block "delete_environement" block editbashrc = chef::util::fileedit.new("/home/oracle/.bash_profile") editbashrc.search_file_delete_line(/^.*#{node['java']['home']} environment settings.*$/) editbashrc.search_file_delete_line(/^.*#auto-generated chef cookbook sun_java.*$/) editbashrc.search_file_delete_line(/^.*export java_home=.*$/) editbashrc.write_file end action :create end remote_file "#{chef::config[:file_cache_path]}/jdk-7u51-linux-x64.rpm" source "http://#######/java/jdk-7u51-linux-x64.rpm" mode "0755" end rpm_package "javarpm" source :"#{chef::config[:file_cache_path]}/jdk-7u51-linux-x64.rpm" only_if {::file.exists?("#{chef::config[:file_cache_path]}/jdk-7u51-linux-x64.rpm")} owner :oracle action :install end # update oracle bash profile ~/.bash_profile execute "create_environment" user "oracle" command "echo -e '#{node['java']['home']} environment settings\n#auto-generated chef cookbook oracle_java\nexport java_home=#{node['java']['home']}' >> ~/.bash_profile" command "echo -e '#{node['java']['home']} environment settings\n#auto-generated chef cookbook oracle_java\nexport path=$path:#{node['java']['home']}/bin' >> ~/.bash_profile" command "source ~/.bash_profile" end file "javarpm-cleanup" path "#{chef::config[:file_cache_path]}/jdk-7u51-linux-x64.rpm" action :delete end

this issue understanding of execute resource. explained in this post:

notice chef going utilize lastly value command attribute. because chef executes in 2 phases - compilation , execution.

so, lastly command in sequence (source ~/.bash_profile) executed.

java path chef recipe

No comments:

Post a Comment