[chef] Re: Re: Chef recipe error


Chronological Thread 
  • From: Daniel DeLeo < >
  • To:
  • Subject: [chef] Re: Re: Chef recipe error
  • Date: Tue, 3 Sep 2013 08:34:32 -0700


On Tuesday, September 3, 2013 at 2:13 AM, Tensibai wrote:

Le 2013-09-03 08:39, David Montgomery a écrit :

 


================================================================================
Error executing action `run` on resource 'execute[source_bashrc]'
================================================================================


Errno::ENOENT
-------------
No such file or directory - source /home/ubuntu/.bashrc


Resource Declaration:
---------------------
# In /home/ubuntu/workspace/Chef/chef-repo/cookbooks/bash/recipes/local.rb

 12: execute "source_bashrc" do
 13:   user "ubuntu"
 14:   command "source /home/ubuntu/.bashrc"
 15:   action :nothing
 16: end
 17:


Quite clear I think, you're trying to execute a command named source by a system call, source is a bult-in inside bash/tcsh/etc.

Change your resource to be bash.

Seen on docs.opscode.com for the execute resource:

Sourcing a file

The execute resource cannot be used to source a file (e.g. command "source filename"). The following example will fail becausesource is not an executable:

execute "foo" do
  command "source /tmp/foo.sh"
end

Instead, use the script resource or one of the script-based resources (bashcshperlpython, or ruby). For example:

bash "foo" do
  code "source /tmp/foo.sh"
end

regards,

Tensibai
 
Additionally, this command isn't going to have the result you're expecting. UNIX processes inherit environment variables from their parent process, but changing environment variables in the child won't affect the parent (if this wasn't the case, changes to things like HOME and PATH would propagate all the way back up to init, and then back down to other users' shells and such).

If you need to set environment variables so that every command chef executes has access to them, then you need to set them via ruby's ENV, for example:

  ENV["PATH"] = "/opt/something/bin:" + ENV["PATH"]

If you only need to set the environment for one or two commands, you can do this with the `environment` attribute of the execute resource: http://docs.opscode.com/resource_execute.html#attributes

HTH,
-- 
Daniel DeLeo




Archive powered by MHonArc 2.6.16.

§