Recipe executing shell command


#1

Hi,

I am trying to create a recipe that will make a silent install of a
jdk1.5. The recipe is like this:

remote_file “#{user_home}/install/jdk-1_5_0_22-linux-amd64.bin” do
source "http://10.1.1.6/files/jdk-1_5_0_22-linux-amd64.bin"
owner user_name
group user_name
mode "0777"
end

remote_file “#{user_home}/install/answerjdk5” do
source "http://10.1.1.6/files/answerjdk5"
owner user_name
group user_name
mode "0755"
end

execute “install_jdk5” do
command "#{user_home}/install/jdk-1_5_0_22-linux-amd64.bin <
#{user_home}/install/answerjdk5 > /dev/null"
action :run
end

The files are downloaded correctly and if I execute the command
manually it works fine. In the client log, everything seems to be ok.
But the jdk folder is not created.

INFO: Processing
remote_file[/home/mee/install/jdk-1_5_0_22-linux-amd64.bin] action
create (dev-env::default line 60)
[Tue, 10 Jan 2012 17:11:38 -0200] INFO: Processing
remote_file[/home/mee/install/answerjdk5] action create
(dev-env::default line 67)
[Tue, 10 Jan 2012 17:11:38 -0200] INFO: Processing
execute[install_jdk5] action run (dev-env::default line 74)
[Tue, 10 Jan 2012 17:11:38 -0200] INFO: execute[install_jdk5]
sh(/home/mee/install/jdk-1_5_0_22-linux-amd64.bin <
/home/mee/install/answerjdk5 > /dev/null)
[Tue, 10 Jan 2012 17:11:40 -0200] INFO: execute[install_jdk5] ran successfully
[Tue, 10 Jan 2012 17:11:41 -0200] INFO: Chef Run complete in 6.528239 seconds
[Tue, 10 Jan 2012 17:11:41 -0200] INFO: Running report handlers
[Tue, 10 Jan 2012 17:11:41 -0200] INFO: Report handlers complete

Can somebody help?

Thanks

Kelly


#2

You may need to use the ‘cwd’ parameter for the execute.

Thanks,
Matt Ray
Senior Technical Evangelist | Opscode Inc.
matt@opscode.com | (512) 731-2218
Twitter, IRC, GitHub: mattray

On Tue, Jan 10, 2012 at 1:13 PM, Kelly Goedert kelly.goedert@gmail.com wrote:

Hi,

I am trying to create a recipe that will make a silent install of a
jdk1.5. The recipe is like this:

remote_file “#{user_home}/install/jdk-1_5_0_22-linux-amd64.bin” do
source "http://10.1.1.6/files/jdk-1_5_0_22-linux-amd64.bin"
owner user_name
group user_name
mode "0777"
end

remote_file “#{user_home}/install/answerjdk5” do
source "http://10.1.1.6/files/answerjdk5"
owner user_name
group user_name
mode "0755"
end

execute “install_jdk5” do
command "#{user_home}/install/jdk-1_5_0_22-linux-amd64.bin <
#{user_home}/install/answerjdk5 > /dev/null"
action :run
end

The files are downloaded correctly and if I execute the command
manually it works fine. In the client log, everything seems to be ok.
But the jdk folder is not created.

INFO: Processing
remote_file[/home/mee/install/jdk-1_5_0_22-linux-amd64.bin] action
create (dev-env::default line 60)
[Tue, 10 Jan 2012 17:11:38 -0200] INFO: Processing
remote_file[/home/mee/install/answerjdk5] action create
(dev-env::default line 67)
[Tue, 10 Jan 2012 17:11:38 -0200] INFO: Processing
execute[install_jdk5] action run (dev-env::default line 74)
[Tue, 10 Jan 2012 17:11:38 -0200] INFO: execute[install_jdk5]
sh(/home/mee/install/jdk-1_5_0_22-linux-amd64.bin <
/home/mee/install/answerjdk5 > /dev/null)
[Tue, 10 Jan 2012 17:11:40 -0200] INFO: execute[install_jdk5] ran successfully
[Tue, 10 Jan 2012 17:11:41 -0200] INFO: Chef Run complete in 6.528239 seconds
[Tue, 10 Jan 2012 17:11:41 -0200] INFO: Running report handlers
[Tue, 10 Jan 2012 17:11:41 -0200] INFO: Report handlers complete

Can somebody help?

Thanks

Kelly


#3

i would try “bash -x ./…bin …” to see exactly what the shell is executing

On Tue, Jan 10, 2012 at 8:14 PM, Matt Ray matt@opscode.com wrote:

You may need to use the ‘cwd’ parameter for the execute.

Thanks,
Matt Ray
Senior Technical Evangelist | Opscode Inc.
matt@opscode.com | (512) 731-2218
Twitter, IRC, GitHub: mattray

On Tue, Jan 10, 2012 at 1:13 PM, Kelly Goedert kelly.goedert@gmail.com wrote:

Hi,

I am trying to create a recipe that will make a silent install of a
jdk1.5. The recipe is like this:

remote_file “#{user_home}/install/jdk-1_5_0_22-linux-amd64.bin” do
source "http://10.1.1.6/files/jdk-1_5_0_22-linux-amd64.bin"
owner user_name
group user_name
mode "0777"
end

remote_file “#{user_home}/install/answerjdk5” do
source "http://10.1.1.6/files/answerjdk5"
owner user_name
group user_name
mode "0755"
end

execute “install_jdk5” do
command "#{user_home}/install/jdk-1_5_0_22-linux-amd64.bin <
#{user_home}/install/answerjdk5 > /dev/null"
action :run
end

The files are downloaded correctly and if I execute the command
manually it works fine. In the client log, everything seems to be ok.
But the jdk folder is not created.

INFO: Processing
remote_file[/home/mee/install/jdk-1_5_0_22-linux-amd64.bin] action
create (dev-env::default line 60)
[Tue, 10 Jan 2012 17:11:38 -0200] INFO: Processing
remote_file[/home/mee/install/answerjdk5] action create
(dev-env::default line 67)
[Tue, 10 Jan 2012 17:11:38 -0200] INFO: Processing
execute[install_jdk5] action run (dev-env::default line 74)
[Tue, 10 Jan 2012 17:11:38 -0200] INFO: execute[install_jdk5]
sh(/home/mee/install/jdk-1_5_0_22-linux-amd64.bin <
/home/mee/install/answerjdk5 > /dev/null)
[Tue, 10 Jan 2012 17:11:40 -0200] INFO: execute[install_jdk5] ran successfully
[Tue, 10 Jan 2012 17:11:41 -0200] INFO: Chef Run complete in 6.528239 seconds
[Tue, 10 Jan 2012 17:11:41 -0200] INFO: Running report handlers
[Tue, 10 Jan 2012 17:11:41 -0200] INFO: Report handlers complete

Can somebody help?

Thanks

Kelly


#4

Running the chef-client with “-l debug” will also show you more output.

Thanks,
Matt Ray
Senior Technical Evangelist | Opscode Inc.
matt@opscode.com | (512) 731-2218
Twitter, IRC, GitHub: mattray

On Tue, Jan 10, 2012 at 1:26 PM, Bryan Berry bryan.berry@gmail.com wrote:

i would try “bash -x ./…bin …” to see exactly what the shell is executing

On Tue, Jan 10, 2012 at 8:14 PM, Matt Ray matt@opscode.com wrote:

You may need to use the ‘cwd’ parameter for the execute.

Thanks,
Matt Ray
Senior Technical Evangelist | Opscode Inc.
matt@opscode.com | (512) 731-2218
Twitter, IRC, GitHub: mattray

On Tue, Jan 10, 2012 at 1:13 PM, Kelly Goedert kelly.goedert@gmail.com wrote:

Hi,

I am trying to create a recipe that will make a silent install of a
jdk1.5. The recipe is like this:

remote_file “#{user_home}/install/jdk-1_5_0_22-linux-amd64.bin” do
source "http://10.1.1.6/files/jdk-1_5_0_22-linux-amd64.bin"
owner user_name
group user_name
mode "0777"
end

remote_file “#{user_home}/install/answerjdk5” do
source "http://10.1.1.6/files/answerjdk5"
owner user_name
group user_name
mode "0755"
end

execute “install_jdk5” do
command "#{user_home}/install/jdk-1_5_0_22-linux-amd64.bin <
#{user_home}/install/answerjdk5 > /dev/null"
action :run
end

The files are downloaded correctly and if I execute the command
manually it works fine. In the client log, everything seems to be ok.
But the jdk folder is not created.

INFO: Processing
remote_file[/home/mee/install/jdk-1_5_0_22-linux-amd64.bin] action
create (dev-env::default line 60)
[Tue, 10 Jan 2012 17:11:38 -0200] INFO: Processing
remote_file[/home/mee/install/answerjdk5] action create
(dev-env::default line 67)
[Tue, 10 Jan 2012 17:11:38 -0200] INFO: Processing
execute[install_jdk5] action run (dev-env::default line 74)
[Tue, 10 Jan 2012 17:11:38 -0200] INFO: execute[install_jdk5]
sh(/home/mee/install/jdk-1_5_0_22-linux-amd64.bin <
/home/mee/install/answerjdk5 > /dev/null)
[Tue, 10 Jan 2012 17:11:40 -0200] INFO: execute[install_jdk5] ran successfully
[Tue, 10 Jan 2012 17:11:41 -0200] INFO: Chef Run complete in 6.528239 seconds
[Tue, 10 Jan 2012 17:11:41 -0200] INFO: Running report handlers
[Tue, 10 Jan 2012 17:11:41 -0200] INFO: Report handlers complete

Can somebody help?

Thanks

Kelly


#5

Adding the cwd parameter solved the problem

Thanks

On Tue, Jan 10, 2012 at 5:14 PM, Matt Ray matt@opscode.com wrote:

You may need to use the ‘cwd’ parameter for the execute.

Thanks,
Matt Ray
Senior Technical Evangelist | Opscode Inc.
matt@opscode.com | (512) 731-2218
Twitter, IRC, GitHub: mattray

On Tue, Jan 10, 2012 at 1:13 PM, Kelly Goedert kelly.goedert@gmail.com wrote:

Hi,

I am trying to create a recipe that will make a silent install of a
jdk1.5. The recipe is like this:

remote_file “#{user_home}/install/jdk-1_5_0_22-linux-amd64.bin” do
source "http://10.1.1.6/files/jdk-1_5_0_22-linux-amd64.bin"
owner user_name
group user_name
mode "0777"
end

remote_file “#{user_home}/install/answerjdk5” do
source "http://10.1.1.6/files/answerjdk5"
owner user_name
group user_name
mode "0755"
end

execute “install_jdk5” do
command "#{user_home}/install/jdk-1_5_0_22-linux-amd64.bin <
#{user_home}/install/answerjdk5 > /dev/null"
action :run
end

The files are downloaded correctly and if I execute the command
manually it works fine. In the client log, everything seems to be ok.
But the jdk folder is not created.

INFO: Processing
remote_file[/home/mee/install/jdk-1_5_0_22-linux-amd64.bin] action
create (dev-env::default line 60)
[Tue, 10 Jan 2012 17:11:38 -0200] INFO: Processing
remote_file[/home/mee/install/answerjdk5] action create
(dev-env::default line 67)
[Tue, 10 Jan 2012 17:11:38 -0200] INFO: Processing
execute[install_jdk5] action run (dev-env::default line 74)
[Tue, 10 Jan 2012 17:11:38 -0200] INFO: execute[install_jdk5]
sh(/home/mee/install/jdk-1_5_0_22-linux-amd64.bin <
/home/mee/install/answerjdk5 > /dev/null)
[Tue, 10 Jan 2012 17:11:40 -0200] INFO: execute[install_jdk5] ran successfully
[Tue, 10 Jan 2012 17:11:41 -0200] INFO: Chef Run complete in 6.528239 seconds
[Tue, 10 Jan 2012 17:11:41 -0200] INFO: Running report handlers
[Tue, 10 Jan 2012 17:11:41 -0200] INFO: Report handlers complete

Can somebody help?

Thanks

Kelly