StackStorm / st2

StackStorm (aka "IFTTT for Ops") is event-driven automation for auto-remediation, incident responses, troubleshooting, deployments, and more for DevOps and SREs. Includes rules engine, workflow, 160 integration packs with 6000+ actions (see https://exchange.stackstorm.org) and ChatOps. Installer at https://docs.stackstorm.com/install/index.html
https://stackstorm.com/
Apache License 2.0
6.07k stars 749 forks source link

Environment variables are confusing in python actions and shell actions. #1646

Closed lakshmi-kannan closed 8 years ago

lakshmi-kannan commented 9 years ago

Shell actions like core.local and core.remote run as system_user whereas python actions run as user as which st2 processes run. So setting environment variables needs to happen for different users for different actions. We need a less confusing way. Perhaps some documentation around this.

Reported by: @skarmark on freenode.

Kami commented 9 years ago

To clarify some things (things also need to be clarified in the docs):

By default, st2actionrunner should also run under system_user (stanley) and as such, the result should be the same, unless user wants to run a local runner action under a different user or use sudo to run it as a root.

In this case, we will use sudo and the result will depend on the sudo settings (e.g. should environment variables be preserved or not).

Kami commented 9 years ago

Edit: Actually, I just had a look - we use sudo -E, but user still needs to put setenv option in the sudoers file otherwise environment won't be preserved and -E wont have an affect.

Kami commented 9 years ago

To clarify my comment and question on IRC - that's how it works right now as long as you correctly run st2actionrunner under stanley (system) user.

If you want to use a custom (non stanley / system) user, you need give him paswordless sudo access if you want to run local runner actions as a different user and as a root. In addition to that, you also need to make sure SETENV sudoers option is set for that user - otherwise environment variables would be preserved when running action as a different / root user.

Kami commented 9 years ago

@skarmark Please let me know if my comment above and documentation updates make it more clear and resolve this issue.

lakshmi-kannan commented 8 years ago

@skarmark ping! can you answer kami's question?

skarmark commented 8 years ago

Yes, it is clear. Sorry about the delay! Somehow missed the update on this thread.

Kami commented 8 years ago

Thanks for letting us know.

Closing this issue.