mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-24 05:40:23 -07:00
windows: removed deprecated features in 2.6 (#38930)
* windows: removed deprecated features in 2.6 * Comma surgery.
This commit is contained in:
parent
8d77c6cc16
commit
f8853d83e3
15 changed files with 32 additions and 197 deletions
|
@ -4,8 +4,7 @@
|
|||
# Copyright: (c) 2017, Dag Wieers <dag@wieers.com>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
# WANT_JSON
|
||||
# POWERSHELL_COMMON
|
||||
#Requires -Module Ansible.ModuleUtils.Legacy
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
|
@ -19,7 +18,6 @@ $verbosity = Get-AnsibleParam -obj $params -name "_ansible_verbosity" -type "int
|
|||
|
||||
$package = Get-AnsibleParam -obj $params -name "name" -type "str" -failifempty $true
|
||||
$force = Get-AnsibleParam -obj $params -name "force" -type "bool" -default $false
|
||||
$upgrade = Get-AnsibleParam -obj $params -name "upgrade" -type "bool" -default $false
|
||||
$version = Get-AnsibleParam -obj $params -name "version" -type "str"
|
||||
$source = Get-AnsibleParam -obj $params -name "source" -type "str"
|
||||
$showlog = Get-AnsibleParam -obj $params -name "showlog" -type "bool" -default $false
|
||||
|
@ -40,15 +38,6 @@ $result = @{
|
|||
changed = $false
|
||||
}
|
||||
|
||||
if ($upgrade)
|
||||
{
|
||||
Add-DeprecationWarning -obj $result -message "Parameter upgrade=yes is replaced with state=latest" -version 2.6
|
||||
if ($state -eq "present")
|
||||
{
|
||||
$state = "latest"
|
||||
}
|
||||
}
|
||||
|
||||
Function Chocolatey-Install-Upgrade
|
||||
{
|
||||
[CmdletBinding()]
|
||||
|
@ -78,8 +67,6 @@ Function Chocolatey-Install-Upgrade
|
|||
$result.rc = $LastExitCode
|
||||
$result.stdout = $install_output | Out-String
|
||||
if ($result.rc -ne 0) {
|
||||
# Deprecated below result output in v2.4, remove in v2.6
|
||||
$result.choco_bootstrap_output = $install_output
|
||||
Fail-Json -obj $result -message "Chocolatey bootstrap installation failed."
|
||||
}
|
||||
$result.changed = $true
|
||||
|
@ -163,9 +150,6 @@ Function Choco-IsInstalled
|
|||
$result.rc = $LastExitCode
|
||||
$result.command = "$script:executable list $options"
|
||||
$result.stdout = $output | Out-String
|
||||
# Deprecated below result output in v2.4, remove in v2.6
|
||||
$result.choco_error_cmd = $result.command
|
||||
$result.choco_error_log = $output
|
||||
Fail-Json -obj $result -message "Error checking installation status for $package 'package'"
|
||||
}
|
||||
|
||||
|
@ -295,9 +279,6 @@ Function Choco-Upgrade
|
|||
if ($result.rc -notin $successexitcodes) {
|
||||
$result.command = "$script:executable upgrade $script:options $options"
|
||||
$result.stdout = $output | Out-String
|
||||
# Deprecated below result output in v2.4, remove in v2.6
|
||||
$result.choco_error_cmd = $result.command
|
||||
$result.choco_error_log = $output
|
||||
Fail-Json -obj $result -message "Error upgrading package '$package'"
|
||||
}
|
||||
|
||||
|
@ -442,9 +423,6 @@ Function Choco-Install
|
|||
if ($result.rc -notin $successexitcodes) {
|
||||
$result.command = "$script:executable install $script:options $options"
|
||||
$result.stdout = $output | Out-String
|
||||
# Deprecated below result output in v2.4, remove in v2.6
|
||||
$result.choco_error_cmd = $result.command
|
||||
$result.choco_error_log = $output
|
||||
Fail-Json -obj $result -message "Error installing package '$package'"
|
||||
}
|
||||
|
||||
|
@ -513,9 +491,6 @@ Function Choco-Uninstall
|
|||
if ($result.rc -notin $successexitcodes) {
|
||||
$result.command = "$script:executable uninstall $script:options $options"
|
||||
$result.stdout = $output | Out-String
|
||||
# Deprecated below result output in v2.4, remove in v2.6
|
||||
$result.choco_error_cmd = $result.command
|
||||
$result.choco_error_log = $output
|
||||
Fail-Json -obj $result -message "Error uninstalling package '$package'"
|
||||
}
|
||||
|
||||
|
|
|
@ -44,12 +44,6 @@ options:
|
|||
- Using C(force) will cause ansible to always report that a change was made.
|
||||
type: bool
|
||||
default: 'no'
|
||||
upgrade:
|
||||
description:
|
||||
- If package is already installed it, try to upgrade to the latest version or to the specified version.
|
||||
- As of Ansible v2.3 this is deprecated, set parameter C(state) to C(latest) for the same result.
|
||||
type: bool
|
||||
default: 'no'
|
||||
version:
|
||||
description:
|
||||
- Specific version of the package to be installed.
|
||||
|
@ -210,21 +204,6 @@ EXAMPLES = r'''
|
|||
'''
|
||||
|
||||
RETURN = r'''
|
||||
choco_bootstrap_output:
|
||||
description: DEPRECATED, will be removed in 2.6, use stdout instead.
|
||||
returned: changed, choco task returned a failure
|
||||
type: str
|
||||
sample: Chocolatey upgraded 1/1 packages.
|
||||
choco_error_cmd:
|
||||
description: DEPRECATED, will be removed in 2.6, use command instead.
|
||||
returned: changed, choco task returned a failure
|
||||
type: str
|
||||
sample: choco.exe install -r --no-progress -y sysinternals --timeout 2700 --failonunfound
|
||||
choco_error_log:
|
||||
description: DEPRECATED, will be removed in 2.6, use stdout instead.
|
||||
returned: changed, choco task returned a failure
|
||||
type: str
|
||||
sample: sysinternals not installed. The package was not found with the source(s) listed
|
||||
command:
|
||||
description: The full command used in the chocolatey task.
|
||||
returned: changed
|
||||
|
|
|
@ -18,16 +18,10 @@ $check_mode = Get-AnsibleParam -obj $params -name "_ansible_check_mode" -type "b
|
|||
$name = Get-AnsibleParam -obj $params -name "name" -type "list" -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
|
||||
$include_sub_features = Get-AnsibleParam -obj $params -name "include_sub_features" -type "bool" -default $false
|
||||
$include_management_tools = Get-AnsibleParam -obj $params -name "include_management_tools" -type "bool" -default $false
|
||||
$source = Get-AnsibleParam -obj $params -name "source" -type "str"
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
$install_cmdlet = $false
|
||||
if (Get-Command -Name Install-WindowsFeature -ErrorAction SilentlyContinue) {
|
||||
Set-Alias -Name Install-AnsibleWindowsFeature -Value Install-WindowsFeature
|
||||
|
@ -43,8 +37,8 @@ if (Get-Command -Name Install-WindowsFeature -ErrorAction SilentlyContinue) {
|
|||
if ($state -eq "present") {
|
||||
$install_args = @{
|
||||
Name = $name
|
||||
Restart = $restart
|
||||
IncludeAllSubFeature = $include_sub_features
|
||||
Restart = $false
|
||||
WhatIf = $check_mode
|
||||
ErrorAction = "Stop"
|
||||
}
|
||||
|
@ -68,7 +62,7 @@ if ($state -eq "present") {
|
|||
} else {
|
||||
$uninstall_args = @{
|
||||
Name = $name
|
||||
Restart = $restart
|
||||
Restart = $false
|
||||
WhatIf = $check_mode
|
||||
ErrorAction = "Stop"
|
||||
}
|
||||
|
@ -115,7 +109,7 @@ $result.reboot_required = ConvertTo-Bool -obj $action_results.RestartNeeded
|
|||
# controls whether Ansible will fail or not
|
||||
$result.failed = (-not $action_results.Success)
|
||||
|
||||
# DEPRECATED 2.4, potential removal in 2.6+ (standardize naming to "reboot_required")
|
||||
# DEPRECATED 2.4, remove in 2.8 (standardize naming to "reboot_required")
|
||||
$result.restart_needed = $result.reboot_required
|
||||
|
||||
Exit-Json -obj $result
|
||||
|
|
|
@ -32,13 +32,6 @@ options:
|
|||
- State of the features or roles on the system.
|
||||
choices: [ absent, present ]
|
||||
default: present
|
||||
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.
|
||||
type: bool
|
||||
default: 'no'
|
||||
include_sub_features:
|
||||
description:
|
||||
- Adds all subfeatures of the specified feature.
|
||||
|
|
|
@ -1,24 +1,10 @@
|
|||
#!powershell
|
||||
|
||||
# (c) 2015, Henrik Wallström <henrik@wallstroms.nu>
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
# Copyright: (c) 2015, Henrik Wallström <henrik@wallstroms.nu>
|
||||
# Copyright: (c) 2017, Ansible Project
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
# WANT_JSON
|
||||
# POWERSHELL_COMMON
|
||||
#Requires -Module Ansible.ModuleUtils.Legacy
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
|
@ -51,12 +37,7 @@ if ($input_attributes) {
|
|||
# Uses dict style parameters, newer and recommended style
|
||||
$attributes = $input_attributes
|
||||
} else {
|
||||
# Uses older style of separating with | per key pair and : for key:value (paramA:valueA|paramB:valueB)
|
||||
Add-DeprecationWarning -obj $result -message "Using a string for the attributes parameter is deprecated, please use a dict instead" -version 2.6
|
||||
$input_attributes -split '\|' | ForEach-Object {
|
||||
$key, $value = $_ -split "\:"
|
||||
$attributes.$key = $value
|
||||
}
|
||||
Fail-Json -obj $result -message "Using a string for the attributes parameter is not longer supported, please use a dict instead"
|
||||
}
|
||||
}
|
||||
$result.attributes = $attributes
|
||||
|
|
|
@ -18,8 +18,8 @@ description:
|
|||
options:
|
||||
attributes:
|
||||
description:
|
||||
- As of Ansible 2.4, this field can take in dict entries to set the
|
||||
application pool attributes.
|
||||
- This field is a free form dictionary value for the application pool
|
||||
attributes.
|
||||
- These attributes are based on the naming standard at
|
||||
U(https://www.iis.net/configreference/system.applicationhost/applicationpools/add#005),
|
||||
see the examples section for more details on how to set this.
|
||||
|
@ -36,11 +36,6 @@ options:
|
|||
keystore. Please follow
|
||||
U(http://structuredsight.com/2014/10/26/im-out-of-range-youre-out-of-range/)
|
||||
to help fix your host.
|
||||
- DEPRECATED As of Ansible 2.4 this field should be set using a dict
|
||||
form, in older versions of Ansible this field used to be a string.
|
||||
- This string has attributes that are separated by a pipe '|' and
|
||||
attribute name/values by colon ':'
|
||||
Ex. "startMode:OnDemand|managedPipelineMode:Classic".
|
||||
name:
|
||||
description:
|
||||
- Name of the application pool.
|
||||
|
@ -89,13 +84,6 @@ EXAMPLES = r'''
|
|||
managedRuntimeVersion: v4.0
|
||||
autoStart: no
|
||||
|
||||
# Note this format style has been deprecated, please use the newer dict style instead
|
||||
- name: change application pool attributes using older string style
|
||||
win_iis_webapppool:
|
||||
name: AppPool
|
||||
attributes: 'managedRuntimeVersion:v4.0|autoStart:false'
|
||||
|
||||
# This is the preferred style to use when setting attributes
|
||||
- name: creates an application pool, sets attributes and starts it
|
||||
win_iis_webapppool:
|
||||
name: AnotherAppPool
|
||||
|
|
|
@ -16,7 +16,6 @@ $check_mode = Get-AnsibleParam -obj $params -name "_ansible_check_mode" -type "b
|
|||
|
||||
$arguments = Get-AnsibleParam -obj $params -name "arguments"
|
||||
$expected_return_code = Get-AnsibleParam -obj $params -name "expected_return_code" -type "list" -default @(0, 3010)
|
||||
$name = Get-AnsibleParam -obj $params -name "name" -type "str"
|
||||
$path = Get-AnsibleParam -obj $params -name "path" -type "str"
|
||||
$product_id = Get-AnsibleParam -obj $params -name "product_id" -type "str" -aliases "productid"
|
||||
$state = Get-AnsibleParam -obj $params -name "state" -type "str" -default "present" -validateset "absent","present" -aliases "ensure"
|
||||
|
@ -30,7 +29,7 @@ $creates_service = Get-AnsibleParam -obj $params -name "creates_service" -type "
|
|||
$result = @{
|
||||
changed = $false
|
||||
reboot_required = $false
|
||||
restart_required = $false # deprecate in 2.6
|
||||
restart_required = $false # deprecate in 2.8
|
||||
}
|
||||
|
||||
if ($arguments -ne $null) {
|
||||
|
@ -60,15 +59,6 @@ if ($username -ne $null) {
|
|||
$credential = New-Object -TypeName PSCredential -ArgumentList $username, $sec_user_password
|
||||
}
|
||||
|
||||
if ($name -ne $null) {
|
||||
Add-DeprecationWarning -obj $result -message "the use of name has been deprecated, please remove from the task options" -version 2.6
|
||||
}
|
||||
|
||||
# validate initial arguments, more is done after analysing the exec path
|
||||
if ($expected_return_code -eq "") {
|
||||
Add-DeprecationWarning -obj $result -message "an empty string for expected_return_code will be deprecated in the future, omit the value or set it explicitly if you wish to override it" -version 2.6
|
||||
$expected_return_code = @(0, 3010)
|
||||
}
|
||||
$valid_return_codes = @()
|
||||
foreach ($rc in ($expected_return_code)) {
|
||||
try {
|
||||
|
@ -373,7 +363,7 @@ if ($state -eq "absent") {
|
|||
}
|
||||
|
||||
$result.rc = $process_result.rc
|
||||
$result.exit_code = $process_result.rc # deprecate in 2.6
|
||||
$result.exit_code = $process_result.rc # deprecate in 2.8
|
||||
if ($valid_return_codes -notcontains $process_result.rc) {
|
||||
$result.stdout = Convert-Encoding -string $process_result.stdout
|
||||
$result.stderr = Convert-Encoding -string $process_result.stderr
|
||||
|
@ -456,7 +446,7 @@ if ($state -eq "absent") {
|
|||
}
|
||||
|
||||
$result.rc = $process_result.rc
|
||||
$result.exit_code = $process_result.rc # deprecate in 2.6
|
||||
$result.exit_code = $process_result.rc # deprecate in 2.8
|
||||
if ($valid_return_codes -notcontains $process_result.rc) {
|
||||
$result.stdout = Convert-Encoding -string $process_result.stdout
|
||||
$result.stderr = Convert-Encoding -string $process_result.stderr
|
||||
|
|
|
@ -60,11 +60,6 @@ options:
|
|||
- A return code of C(3010) usually means that a reboot is required, the
|
||||
C(reboot_required) return value is set if the return code is C(3010).
|
||||
default: [0, 3010]
|
||||
name:
|
||||
description:
|
||||
- Name of the package, if name isn't specified the path will be used for
|
||||
log messages.
|
||||
- As of Ansible 2.4 this is deprecated and no longer required.
|
||||
password:
|
||||
description:
|
||||
- The password for C(user_name), must be set when C(user_name) is.
|
||||
|
|
|
@ -174,12 +174,6 @@ namespace Ansible
|
|||
}
|
||||
'@
|
||||
|
||||
# Fix HCCC:\ PSDrive for pre-2.3 compatibility
|
||||
if ($path -match "^HCCC:\\") {
|
||||
Add-DeprecationWarning -obj $result -message "Please use path: HKCC:\... instead of path: $path" -version 2.6
|
||||
$path = $path -replace "HCCC:\\","HKCC:\\"
|
||||
}
|
||||
|
||||
# fire a warning if the property name isn't specified, the (Default) key ($null) can only be a string
|
||||
if ($name -eq $null -and $type -ne "string") {
|
||||
Add-Warning -obj $result -message "the data type when name is not specified can only be 'string', the type has automatically been converted"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue