.profile not getting executed on chef client -


i have following recipe on chef-server:

# insert environment variables in .profile execute "set-env-path"   command "echo 'export java_home=/home/node/jdk1.6.0_45' >> /home/node/.profile && echo 'export path=$path:$java_home/bin' >> /home/node/.profile" end  # execute .profile execute "execute .profie"   command ". $home/.profile" end  

when running recipe on client, environment variables gets inserted .profile not getting set.

node@node-virtual-machine:~$ sudo chef-client [2014-04-07t14:59:57+05:30] info: forking chef instance converge... starting chef client, version 11.10.4 [2014-04-07t14:59:57+05:30] info: *** chef 11.10.4 ***  [2014-04-07t14:59:57+05:30] info: chef-client pid: 24177 [2014-04-07t14:59:57+05:30] info: run list [recipe[remote_file]] [2014-04-07t14:59:57+05:30] info: run list expands [remote_file] [2014-04-07t14:59:57+05:30] info: starting chef run node-virtual-machine [2014-04-07t14:59:57+05:30] info: running start handlers [2014-04-07t14:59:57+05:30] info: start handlers complete. [2014-04-07t14:59:58+05:30] info: http request returned 404 object not found:  resolving cookbooks run list: ["remote_file"] [2014-04-07t14:59:58+05:30] info: loading cookbooks [remote_file] synchronizing cookbooks: [2014-04-07t14:59:58+05:30] info: storing updated cookbooks/remote_file/recipes/default.rb in cache.   - remote_file     compiling cookbooks... converging 2 resources recipe: remote_file::default   * execute[set-env-path] action run[2014-04-07t14:59:58+05:30] info: processing execute[set-env-path] action run (remote_file::default line 39) [2014-04-07t14:59:58+05:30] info: execute[set-env-path] ran  - execute echo 'export java_home=/home/node/jdk1.6.0_45' >> /home/node/.profile && echo 'export path=$path:$java_home/bin' >> /home/node/.profile  * execute[set-env-path2] action run[2014-04-07t14:59:58+05:30] info: processing execute[set-env-path2] action run (remote_file::default line 44) [2014-04-07t14:59:58+05:30] info: execute[set-env-path2] ran  - execute . $home/.profile  [2014-04-07t14:59:58+05:30] info: chef run complete in 0.511487679 seconds  running handlers: [2014-04-07t14:59:58+05:30] info: running report handlers running handlers complete  [2014-04-07t14:59:58+05:30] info: report handlers complete chef client finished, 2/2 resources updated in 1.150640709 seconds node@node-virtual-machine:~$ echo $java_home  node@node-virtual-machine: 

why .profile file not getting executed on chef client, why environment variables not getting set via chef?

when chef runs execute resources (including bash, script, etc), executed in subshell. setting environment subshell, not chef client process. if need set environment variables, you'll need use ruby block , env hash:

ruby_block 'set environment'   block     env['my_variable'] = 'my_value'   end end 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -