ansible.windows.win_path module – Manage Windows path environment variables
Note
This module is part of the ansible.windows collection (version 2.5.0).
You might already have this collection installed if you are using the ansible
package.
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install ansible.windows
.
To use it in a playbook, specify: ansible.windows.win_path
.
Synopsis
Allows element-based ordering, addition, and removal of Windows path environment variables.
Parameters
Parameter |
Comments |
---|---|
A single path element, or a list of path elements (ie, directories) to add or remove. When multiple elements are included in the list (and Variable expansions (eg, Any existing path elements not mentioned in New path elements are appended to the path, and existing path elements may be moved closer to the end to satisfy the requested ordering. Paths are compared in a case-insensitive fashion, and trailing backslashes are ignored for comparison purposes. However, note that trailing backslashes in YAML require quotes. |
|
Target path environment variable name. Default: |
|
The level at which the environment variable specified by Choices:
|
|
Whether the path elements specified in Choices:
|
Notes
Note
This module is for modifying individual elements of path-like environment variables. For general-purpose management of other environment vars, use the ansible.windows.win_environment module.
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 an interactive user to log out and in again before they become available.
See Also
See also
- ansible.windows.win_environment
Modify environment variables on windows hosts.
Examples
- name: Ensure that system32 and Powershell are present on the global system path, and in the specified order
ansible.windows.win_path:
elements:
- '%SystemRoot%\system32'
- '%SystemRoot%\system32\WindowsPowerShell\v1.0'
- name: Ensure that C:\Program Files\MyJavaThing is not on the current user's CLASSPATH
ansible.windows.win_path:
name: CLASSPATH
elements: C:\Program Files\MyJavaThing
scope: user
state: absent