Support for getting and setting the environment variables of the current salt process.
Get a single salt process environment variable.
String used as the key for environment lookup.
If the key is not found in the environment, return this value. Default: ''
CLI Example:
salt '*' environ.get foo
salt '*' environ.get baz default=False
Determine whether the key exists in the current salt process environment dictionary. Optionally compare the current value of the environment against the supplied value string.
Must be a string. Used as key for environment lookup.
Optional. If key exists in the environment, compare the current value with this value. Return True if they are equal.
CLI Example:
salt '*' environ.has_value foo
Get one or more salt process environment variables. Returns a dict.
Either a string or a list of strings that will be used as the keys for environment lookup.
If the key is not found in the environment, return this value. Default: ''
CLI Example:
salt '*' environ.item foo
salt '*' environ.item '[foo, baz]' default=None
Return a dict of the entire environment set for the salt process
CLI Example:
salt '*' environ.items
Set multiple salt process environment variables from a dict. Returns a dict.
Must be a dict. The top-level keys of the dict are the names of the environment variables to set. Each key's value must be a string or False. Refer to the 'false_unsets' parameter for behavior when a value set to False.
If a key's value is False and false_unsets is True, then the key will be removed from the salt processes environment dict entirely. If a key's value is False and false_unsets is not True, then the key's value will be set to an empty string. Default: False
USE WITH CAUTION! This option can unset environment variables needed for salt to function properly. If clear_all is True, then any environment variables not defined in the environ dict will be deleted. Default: False
If True, apply these environ changes to the main salt-minion process. If False, the environ changes will only affect the current salt subprocess. Default: False
On Windows minions this will set the environment variable in the registry so that it is always added as an environment variable when applications open. If you want to set the variable to HKLM instead of HKCU just pass in "HKLM" for this parameter. On all other minion types this will be ignored. Note: This will only take affect on applications opened after this has been set.
CLI Example:
salt '*' environ.setenv '{"foo": "bar", "baz": "quux"}'
salt '*' environ.setenv '{"a": "b", "c": False}' false_unsets=True
Set a single salt process environment variable. Returns True on success.
The environment key to set. Must be a string.
The value to set. Must be a string or False. Refer to the 'false_unsets' parameter for behavior when set to False.
If val is False and false_unsets is True, then the key will be removed from the salt processes environment dict entirely. If val is False and false_unsets is not True, then the key's value will be set to an empty string. Default: False.
On Windows minions this will set the environment variable in the registry so that it is always added as an environment variable when applications open. If you want to set the variable to HKLM instead of HKCU just pass in "HKLM" for this parameter. On all other minion types this will be ignored. Note: This will only take affect on applications opened after this has been set.
CLI Example:
salt '*' environ.setval foo bar
salt '*' environ.setval baz val=False false_unsets=True
salt '*' environ.setval baz bar permanent=True
salt '*' environ.setval baz bar permanent=HKLM