W3cubDocs

/Ansible

win_environment - Modifies environment variables on windows hosts.

New in version 2.0.

Synopsis

Uses .net Environment to set or remove environment variables and can set at User, Machine or Process level. User level environment variables will be set, but not available until the user has logged off and on again.

Options

parameter required default choices comments
level
yes no default
  • machine
  • process
  • user
The level at which to set the environment variable.
Use 'machine' to set for all users.
Use 'user' to set for the current user that ansible is connected as.
Use 'process' to set for the current process. Probably not that useful.
name
yes no default
The name of the environment variable
state
no present
  • present
  • absent
present to ensure environment variable is set, or absent to ensure it is removed
value
no no default
The value to store in the environment variable. Can be omitted for state=absent

Examples

# Set an environment variable for all users
win_environment:
  state: present
  name: TestVariable
  value: "Test value"
  level: machine
# Remove an environment variable for the current users
win_environment:
  state: absent
  name: TestVariable
  level: user

Notes

Note

This module does not broadcast change events. This means that the minority of windows applications which can have their environment changed without restarting will not be notified and therefore will need restarting to pick up new environment settings. User level environment variables will require the user to log out and in again before they become available.

This is an Extras Module

For more information on what this means please read Extras Modules

For help in developing on modules, should you be so inclined, please read Community Information & Contributing, developing_test_pr and Developing Modules.

© 2012–2016 Michael DeHaan
© 2016 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/win_environment_module.html