saltstack/salt — Issue #789: Ability to set environment variable in cmd states
Author: mattvryan
Created: 2012-02-29 00:12:59+00:00
State: open

It would be cool to be able to specify an environment variable in the cmd state that would be set before the command is executed. Some commands depend on certain environment variables to be set when the command is executed and they don't execute properly if the environment isn't right.

Something like:
my_command:
- cmd:
- env: HOME=/home/myhome

One example where this comes up (where it is biting me lately) is if I try to run Erlang commands from my state. If the HOME environment variable isn't set the command will fail saying HOME must be set. I can usually get around this by changing the command from "my_command" to "HOME=/home/myhome my_command" but this makes my state file a bit messier than I'd like.