Hi all,
Currently, func doesn't set environment variables when run commands on
minions, thus the commands/programs which are executed on minions can not
get proper environment variables. e.g:
# func-command --host="tempt154.ops.example.com" "env"
env
tempt154.ops.example.com:
SHELL=/bin/bash
MAILTO=root
USER=root
LSB=LSB-1.1
PATH=/sbin:/usr/sbin:/bin:/usr/bin
_=/bin/env
PWD=/
LANG=en_US.UTF-8
HOME=/
SHLVL=8
LOGNAME=root
In the above, $HOME is set to '/' instead of '/root', which would trigger
some error for some programs. So do it make sense to make sure the commands
inheritance environments of funcd before they are executed?
BTW, currently I fix this problem by modifying
'func/minion/modules/command.py' like this:
diff --git a/func/minion/modules/command.py b/func/minion/modules/command.py
index 919a487..8ab696a 100644
--- a/func/minion/modules/command.py
+++ b/func/minion/modules/command.py
@@ -28,9 +28,10 @@ class Command(func_module.FuncModule):
Runs a command, returning the return code, stdout, and stderr as a
tuple.
NOT FOR USE WITH INTERACTIVE COMMANDS.
"""
+ sys_env = os.environ.copy()
cmdref = sub_process.Popen(command, stdout=sub_process.PIPE,
stderr=sub_process.PIPE, shell=True,
- close_fds=True, env=env)
+ close_fds=True, env=sys_env)
data = cmdref.communicate()
return (cmdref.returncode, data[0], data[1])
Don't know if this is the right workaround.
_______________________________________________
Func-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/func-list