mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 04:40:22 -07:00
win_environment: Added explicit check for null, empty string with state=present (#40468)
* win_environment: Added explicit check for null, empty string with state=present * Added changelog fragment
This commit is contained in:
parent
5634dae290
commit
db195831fd
4 changed files with 22 additions and 0 deletions
|
@ -28,6 +28,8 @@ $result = @{
|
|||
if ($state -eq "absent" -and $value) {
|
||||
Add-Warning -obj $result -message "When removing environment variable '$name' it should not have a value '$value' set"
|
||||
$value = $null
|
||||
} elseif ($state -eq "present" -and (-not $value)) {
|
||||
Fail-Json -obj $result -message "When state=present, value must be defined and not an empty string, if you wish to remove the envvar, set state=absent"
|
||||
}
|
||||
|
||||
if ($state -eq "present" -and $before_value -ne $value) {
|
||||
|
|
|
@ -30,6 +30,7 @@ options:
|
|||
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).
|
||||
level:
|
||||
description:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue