Is there a way to provide a common set of environment variables to all actions in a pack?


(Alan Robertson) #1

What it says above.

Ideally by a single configuration or file or something which would then provide these variables for all the actions in a pack. This keeps the code from having to be hacked and tweaked to bring into Stackstorm. There are dozens of library environment variables that it’s simply not practical (or reasonable) to hack the underlying libraries to get things working under Stackstorm. My particular application is mostly python.


(Lindsay Hill) #2

I haven’t done any real testing of this, but this may work for you:

Create/edit /etc/default/st2actionrunner (or equivalent for RHEL/CentOS)

extreme@EWC:/etc/default$ cat st2actionrunner
MYVAR=foobar
extreme@EWC:/etc/default$

Then do an st2ctl restart, and test it:

extreme@EWC:/etc/default$ st2 run core.local cmd=env
.
id: 5bc66a0500db59247bd43e41
status: succeeded
parameters:
  cmd: env
result:
  failed: false
  return_code: 0
  stderr: ''
  stdout: 'ST2_ACTION_PACK_NAME=core
    ST2_ACTION_API_URL=http://127.0.0.1:9101/v1
    TERM=linux
    LC_ALL=en_US.UTF-8
    USER=stanley
    WORKERID=2
    SUDO_USER=root
    SUDO_UID=0
    ST2_ACTION_EXECUTION_ID=5bc66a0500db59247bd43e41
    USERNAME=stanley
    PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
    PWD=/
    LANG=en_US.UTF-8
    SHLVL=1
    SUDO_COMMAND=/bin/bash -c env
    HOME=/home/stanley
    ST2_ACTION_AUTH_TOKEN=d96ed5b2f8fa40f8985a24102734864d
    UPSTART_INSTANCE=2
    LOGNAME=stanley
    UPSTART_JOB=st2actionrunner-worker
    SUDO_GID=999
    MYVAR=foobar
    _=/usr/bin/env'
  succeeded: true
extreme@EWC:/etc/default$

(Alan Robertson) #3

That looks like it should work provided one of the parent* processes of the python action runners was a shell. I’ll give it a shot. Thanks @lhill!