【发布时间】:2015-10-07 11:54:08
【问题描述】:
我的厨师服务器上有以下食谱:
# Insert the environment variables in .profile
execute "set-env-path" do
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" do
command ". $HOME/.profile"
end
当我在客户端上运行配方时,环境变量被插入到 .profile 中,但它们没有被设置。
node@node-virtual-machine:~$ sudo chef-client
[2014-04-07T14:59:57+05:30] INFO: Forking chef instance to 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 is [recipe[remote_file]]
[2014-04-07T14:59:57+05:30] INFO: Run List expands to [remote_file]
[2014-04-07T14:59:57+05:30] INFO: Starting Chef Run for 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 for 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 the 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 successfully
- 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 successfully
- 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:
为什么 .profile 文件没有在 chef 客户端上执行,为什么我的环境变量没有通过 chef 设置?
【问题讨论】:
-
有人知道上述解决方案吗?
标签: chef-infra chef-recipe chef-solo