厨师菜谱 - 重新加载PATH [英] Chef cookbook - reload PATH

查看:172
本文介绍了厨师菜谱 - 重新加载PATH的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚使用厨师菜谱安装了java,并为所有用户更新了PATH环境变量(将新文件添加到/etc/profile.d/).

I just installed java using chef cookbook and updated PATH environment variable for all users (added new file to /etc/profile.d/).

是否可能告诉厨师重新加载PATH变量?

Is it possible to tell chef to reload PATH variable?

当我这样做:

execute "java_check" do
  command "java -version"
end

是说找不到java。

当我退出登录,再次登录,然后运行厨师食谱时,它的工作正常。

It works fine when I log out, log in again and then run chef recipe.

推荐答案

我不能100%确定您可以更新PATH变量以供将来的厨师运行,但您可以使用环境属性执行节。这也可以在其他资源中使用。请参阅: http://docs.opscode.com/chef/resources.html#execute

I'm not 100% sure you can update the PATH variable for future chef runs, but you can set it up manually using the environment attribute within the execute stanza. This can also be used on other Resources as well. See: http://docs.opscode.com/chef/resources.html#execute

从Chef Docs中,

From the Chef Docs,

environment
A hash of environment variables: {"ENV_VARIABLE"=>"VALUE"}.
(These environment variables must exist for a command to execute successfully.)
Default value: nil.

运行需要环境变量的命令

Run a command which requires an environment variable

execute "slapadd" do
  command "slapadd < /tmp/something.ldif"
  creates "/var/lib/slapd/uid.bdb"
  action :run
  environment ({'HOME' => '/home/myhome'})
end

这篇关于厨师菜谱 - 重新加载PATH的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆