puppet - 如何附加到路径变量? [英] puppet - How do I append to path variable?

查看:48
本文介绍了puppet - 如何附加到路径变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只能访问我们团队的一个模块,其中全局清单由基础架构团队维护.PATH 变量在全局清单中设置.

I have access to just a module for our team, where as the global manifests are maintained by infrastructure team. The PATH variable gets set in the global manifests.

我想附加到 PATH 变量,但 puppet 忽略了我的 exec 块.

I want to append to the PATH variable, but puppet ignores my exec block.

file { "/etc/profile.d/set_java_home.sh":
    ensure => file,
    source => "puppet:///modules/teamXXX/set_java_home.sh",
    mode => "u=rw,go=r"
}

Exec { path => [ "\${PATH}", "\${JAVA_HOME}/bin" ] }

如何附加到 PATH 变量?

我应该提到,我希望为用户的 shell 环境而不是 puppet 的执行环境增强 PATH 变量.

I should have mentioned, I am looking to enhance the PATH variable for users's shell environment, rather than puppet's execution environment.

推荐答案

Puppet 不能改变正在运行的 shell 的环境.没有子进程可以 - 环境被复制到每个子进程,然后它只能访问其单独的副本.

Puppet cannot change the environment of the running shell. No subprocess can - the environment is copied to each child process, which then only has access to its individual copy.

要将某些内容附加到所有新登录 shell 的 PATH,您需要更改 profile 配置文件.如果您使用的是最新版本的 bash,则应该有一个 /etc/profile.d.您可以使用这样的资源:

To append something to the PATH of all new login shells, you need to change the profile configuration file. If you're using a recent version of bash, there should be a /etc/profile.d. You can use a resource like this:

file { '/etc/profile.d/append-java-path.sh':
    mode    => '644',
    content => 'PATH=$PATH:/my/java/home/bin',
}

这篇关于puppet - 如何附加到路径变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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