Skip to content

Commit

Permalink
Deprecated restart option in win_feature, added return docs
Browse files Browse the repository at this point in the history
  • Loading branch information
nitzmahone committed May 4, 2017
1 parent db91dd8 commit 2052ed4
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 2 deletions.
15 changes: 13 additions & 2 deletions lib/ansible/modules/windows/win_feature.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,18 @@ $check_mode = Get-AnsibleParam -obj $params -name "_ansible_check_mode" -type "b

$name = Get-AnsibleParam -obj $params -name "name" -type "str" -failifempty $true
$state = Get-AnsibleParam -obj $params -name "state" -type "str" -default "present" -validateset "present","absent"

# DEPRECATED 2.4, potential removal in 2.6+
$restart = Get-AnsibleParam -obj $params -name "restart" -type "bool" -default $false
$includesubfeatures = Get-AnsibleParam -obj $params -name "include_sub_features" -type "bool" -default $false
$includemanagementtools = Get-AnsibleParam -obj $params -name "include_management_tools" -type "bool" -default $false
$source = Get-AnsibleParam -obj $params -name "source" -type "str"

$name = $name -split ',' | % { $_.Trim() }

If ($restart) {
Add-DeprecationWarning -obj $result -message "The 'restart' parameter causes instability. Use the 'win_reboot' action conditionally on 'reboot_required' return value instead" -version 2.6
}

# Determine which cmdlets we need to work with. Then we can set options appropriate for the cmdlet
$installWF= $false
Expand Down Expand Up @@ -133,9 +138,12 @@ If ($featureresult.FeatureResult)
id = $item.Id
display_name = $item.DisplayName
message = $message
restart_needed = $item.RestartNeeded.ToString() | ConvertTo-Bool
reboot_required = $item.RestartNeeded.ToString() | ConvertTo-Bool
skip_reason = $item.SkipReason.ToString()
success = $item.Success.ToString() | ConvertTo-Bool

# DEPRECATED 2.4, potential removal in 2.6+ (standardize naming to "reboot_required")
restart_needed = $item.RestartNeeded.ToString() | ConvertTo-Bool
}
}
$result.changed = $true
Expand All @@ -144,7 +152,10 @@ If ($featureresult.FeatureResult)
$result.feature_result = $installed_features
$result.success = ($featureresult.Success.ToString() | ConvertTo-Bool)
$result.exitcode = $featureresult.ExitCode.ToString()
$result.restart_needed = ($featureresult.RestartNeeded.ToString() | ConvertTo-Bool)
$result.reboot_required = ($featureresult.RestartNeeded.ToString() | ConvertTo-Bool)

# DEPRECATED 2.4, potential removal in 2.6+ (standardize naming to "reboot_required")
$result.restart_needed = $result.reboot_required

If ($result.success) {
Exit-Json $result
Expand Down
63 changes: 63 additions & 0 deletions lib/ansible/modules/windows/win_feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
restart:
description:
- Restarts the computer automatically when installation is complete, if restarting is required by the roles or features installed.
- DEPRECATED in Ansible 2.4, as unmanaged reboots cause numerous issues under Ansible. Check the C(reboot_required) return value
from this module to determine if a reboot is necessary, and if so, use the M(win_reboot) action to perform it.
choices:
- yes
- no
Expand Down Expand Up @@ -101,3 +103,64 @@
include_sub_features: True
include_management_tools: True
'''

RETURN = r'''
exitcode:
description: The stringified exit code from the feature installation/removal command
returned: always
type: string
sample: Success
feature_result:
description: List of features that were installed or removed
returned: success
type: complex
sample:
contains:
display_name:
description: Feature display name
returned: always
type: string
sample: "Telnet Client"
id:
description: A list of KB article IDs that apply to the update
returned: always
type: int
sample: 44
message:
description: Any messages returned from the feature subsystem that occurred during installation or removal of this feature
returned: always
type: list of strings
sample: []
reboot_required:
description: True when the target server requires a reboot as a result of installing or removing this feature
returned: always
type: boolean
sample: True
restart_needed:
description: DEPRECATED in Ansible 2.4 (refer to C(reboot_required) instead). True when the target server requires a reboot as a
result of installing or removing this feature
returned: always
type: boolean
sample: True
skip_reason:
description: The reason a feature installation or removal was skipped
returned: always
type: string
sample: NotSkipped
success:
description: If the feature installation or removal was successful
returned: always
type: boolean
sample: True
reboot_required:
description: True when the target server requires a reboot to complete updates (no further updates can be installed until after a reboot)
returned: success
type: boolean
sample: True
restart_needed:
description: DEPRECATED in Ansible 2.4 (refer to C(reboot_required) instead). True when the target server requires a reboot to complete updates
(no further updates can be installed until after a reboot)
returned: success
type: boolean
sample: True
'''

0 comments on commit 2052ed4

Please sign in to comment.