Fabric + DigitalOcean: unvisible ENVIRONMENT VARIABLE?

限于喜欢 提交于 2019-12-11 02:30:41

问题


I have server on DigitalOcean and I use fabric for deploying my code. And my code is dependent on environment variables (flask config). I've faced one strange trouble today: on server in /root/.bashrc I've added next line

export CONFIG=/path/to/conf

And when I executing on remote console

>>> echo $CONFIG
>>> /path/to/conf  # result, as it should be

But in fabfile I have a function

def show():
    run("echo $CONFIG")

And it prints an empty string. WHY? Thanks in advance!


回答1:


This shouldn't be the case, as by default Fabric uses the -l flag which is supposed to Make bash act as if it had been invoked as a login shell (see INVOCATION below).

I am also not able to reproduce your issue:

$ fab -H home test_bash
[home] Executing task 'test_bash'
[home] run: grep FOO $HOME/.bashrc
[home] out: export FOO="BAR"
[home] out:

[home] run: echo $FOO
[home] out: BAR
[home] out:

So my guess is that you've changed the env.shell, or that you're not connecting as the root user which is where you're setting this bash export. (Note that run() isn't the same a sudo() in Fabric usage)



来源:https://stackoverflow.com/questions/22624811/fabric-digitalocean-unvisible-environment-variable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!