访问 rundeck 节点上的环境变量 [英] Accessing environmental variables on rundeck node

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

问题描述

这是一个由两部分组成的问题.我正在使用 rundeck 运行一个脚本,该脚本依赖于对我在/etc/environment.conf 中设置的脚本执行的节点上系统范围的环境变量的访问.

首先,如何让 rundeck 摄取系统环境?我在 rundeck 中找不到任何选项来执行此操作.

第二,为什么默认情况下不会发生这种情况?我的印象是 rundeck 通过 ssh 工作;不是每次登录节点都要加载系统环境吗?

解决方案

首先,如何让 rundeck 摄取系统环境?我不能在 rundeck 中找到任何选项来执行此操作.

我通过添加以下几行来成功执行此操作:

set -a./etc/环境./etc/配置文件

1) 将这些行放入文件:/etc/rundeck/profile

2) 将这些行放入脚本步骤

备注:我在 rundeck 中只使用脚本步骤,并且我总是将这些行放在脚本步骤的第一行:

#!/usr/bin/env bash

<块引用>

第二,为什么默认情况下不会发生这种情况?我印象中该 rundeck 通过 ssh 工作;系统环境不应该是每次登录节点都加载?

我认为您需要在 ssh_config 文件中添加一些内容.检查此链接:Rundeck 未设置环境变量用于使用不同 ssh 端口的远程执行

This is a two-part question. I am running a script using rundeck that depends on access to environmental variables system-wide on the node I'm executing the script on that I have set in /etc/environment.

First, how do I get rundeck to ingest the system environment? I can't find any option in rundeck to do this.

Second, why doesn't this happen by default? I'm under the impression that rundeck works through ssh; shouldn't the system environment be loaded every time it logs in to the node?

解决方案

First, how do I get rundeck to ingest the system environment? I can't find any option in rundeck to do this.

I succeeded to perform this by adding the following lines to:

set -a
. /etc/environment
. /etc/profile

1) put those lines into the file: /etc/rundeck/profile

2) put those lines into a script step

Remark: I'm using only script steps in my rundeck and I'm always put this lines in the first line of the script step:

#!/usr/bin/env bash

Second, why doesn't this happen by default? I'm under the impression that rundeck works through ssh; shouldn't the system environment be loaded every time it logs in to the node?

I think that you need to cinfigre something in the ssh_config file. check this link: Rundeck not setting up environment variable for remote execution with different ssh port

这篇关于访问 rundeck 节点上的环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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