- From: Jeff Byrnes <
>
- To:
- Subject: [chef] Re: Re: Re: Re: Re: Not able to execute .profile in ubuntu through chef recipe
- Date: Wed, 17 Dec 2014 14:00:30 -0500
Aman,
Like Morgan, I’d encourage using the community java cookbook to handle Java’s installation, and then wrap that cookbook to set up the .profile & /etc/profile using the attributes supplied by the java cookbook (namely, node['java']['java_home’]).
Bear in mind that the EnvVars you’re setting in that ruby_block will not persist beyond the Chef run, so I’m not entirely sure why you’re setting them at all.
You might consider this gist: https://gist.github.com/jeffbyrnes/adc37c4e69d0f68b0214
On December 17, 2014 at 2:52:28 AM, aman singh (
">
) wrote:
Hi All
I am not able to set JAVA_HOME and PATH variable through my recipe.
Please refer below my recipe code for java
installation.
Ruby block is accepting path
/opt/app/workload/installed_apps/jdk1.7.0_71 and not including
/opt/app/workload/installed_apps/jdk1.7.0_71'/bin in $PATH
variable.
I have tried execute block, script resource also to run .sh
file but nothing works in my case.
CODE-:
Attributes-:
default['java_manual']['JAVA_HOME'] =
'/opt/app/workload/installed_apps/jdk1.7.0_71'
default['java_manual']['JRE_HOME'] =
'/opt/app/workload/installed_apps/jdk1.7.0_71/jre'
# Cookbook Name:: java_manual
# Recipe:: default
# Copyright 2014, YOUR_COMPANY_NAME
# All rights reserved - Do Not Redistribute
%w[ /app /app/workload /app/workload/installed_apps ].each do
|path|
directory "/opt/#{path}" do
owner 'root'
action :create
end
end
cookbook_file "jdk7.tar.gz" do
path "/opt/app/workload/installed_apps/jdk7.tar.gz"
action :create_if_missing
end
bash "untar java" do
cwd
"/opt/app/workload/installed_apps"
user "root"
code <<-EOH
su -sH
tar xzf jdk7.tar.gz
rm jdk7.tar.gz
EOH
end
#execute "slapadd" do
# environment ({'JAVA_HOME' =>
"#{node['java_manual']['JAVA_HOME']}"})
# command 'export
JAVA_HOME="/opt/app/workload/installed_apps/jdk1.7.0_71"'
# action :run
#end
ruby_block "mydate" do
block do
ENV["JAVA_HOME"] =
"#{node['java_manual']['JAVA_HOME']}"
print
"#{node['java_manual']['JAVA_HOME']}/bin:#{node['java_manual']['JRE_HOME']}/bin:#{ENV['PATH']}"
ENV["PATH"] =
"#{ENV['PATH']}:#{node['java_manual']['JAVA_HOME']}/bin:#{node['java_manual']['JRE_HOME']}/bin"
end
end
Thanks
Amandeep Singh
|
Archive powered by MHonArc 2.6.16.