用木偶设置环境变量 [英] Setting environment variables with puppet

查看:165
本文介绍了用木偶设置环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我可以使用exec,只需要执行 export VAR =嗒嗒。但是,这只会持续到本届会议。我也想到只是把它添加到一个文件的末尾,比如bashrc。然而,我不认为有一个可靠的方法来检查是否已经准备好了;所以最终会增加每一次木偶的运行。

解决方案

我将看一下这个相关的问题



*。sh /etc/profile.d 在用户登录时读取(正如帖子所说,同时 / etc / profile 来源)


$ b $因此,在 /etc/profile.d 中的任何脚本中,变量导出将可用于您的用户。



然后,您可以使用 文件 资源,以确保此操作是幂等。例如:

  file {/etc/profile.d/my_test.sh:
content => 'export MYVAR =123'
}


I'm trying to work out the best way to set some environment variables with puppet.

I could use exec and just do export VAR=blah. However, that would only last for the current session. I also thought about just adding it onto the end of a file such as bashrc. However then I don't think there is a reliable method to check if it is all ready there; so it would end up getting added with every run of puppet.

解决方案

I would take a look at this related question.

*.sh scripts in /etc/profile.d are read at user-login time (as the post says, at the same time /etc/profile is sourced)

Variables export-ed in any script placed in /etc/profile.d will therefore be available to your users.

You can then use a file resource to ensure this action is idempotent. For example:

file { "/etc/profile.d/my_test.sh":
  content => 'export MYVAR="123"'
}

这篇关于用木偶设置环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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