ansible / ansible.builtin / v2.8.20 / module / win_environment Modify environment variables on windows hosts | "added in version" 2.0 of ansible.builtin" Authors: Jon Hawkesworth (@jhawkesworth) preview | supported by communityansible.builtin.win_environment (v2.8.20) — module
pip
Install with pip install ansible==2.8.20
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.
- name: Set an environment variable for all users win_environment: state: present name: TestVariable value: Test value level: machine
- name: Remove an environment variable for the current user win_environment: state: absent name: TestVariable level: user
name: description: - The name of the environment variable. required: true type: str level: choices: - machine - process - user description: - The level at which to set the environment variable. - Use C(machine) to set for all users. - Use C(user) to set for the current user that ansible is connected as. - Use C(process) to set for the current process. Probably not that useful. required: true type: str state: choices: - absent - present default: present description: - Set to C(present) to ensure environment variable is set. - Set to C(absent) to ensure it is removed. type: str value: description: - The value to store in the environment variable. - Must be set when C(state=present) and cannot be an empty string. - Can be omitted for C(state=absent). type: str
before_value: description: the value of the environment key before a change, this is null if it didn't exist returned: always sample: C:\Windows\System32 type: str value: description: the value the environment key has been set to, this is null if removed returned: always sample: C:\Program Files\jdk1.8 type: str