Win deprecate 2.8 (#45473)

* Remove deprecated/expired functionality

* win:_msi: Remove the win_msi module

* removed some missed deprecated return options and added porting guide reference

Co-authored-by: dagwieers <dagwieers@users.noreply.github.com>
This commit is contained in:
Jordan Borean 2018-09-11 14:23:48 +10:00 committed by GitHub
parent ec6d82435f
commit 01398f61d5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 32 additions and 184 deletions

View file

@ -0,0 +1,6 @@
removed_features:
- win_feature - Removed deprecated 'restart_needed' returned boolean, use standardized 'reboot_required' instead
- win_package - Removed deprecated 'restart_required' returned boolean, use standardized 'reboot_required' instead
- win_package - Removed deprecated 'exit_code' returned int, use standardized 'rc' instead
- win_get_url - Removed deprecated 'win_get_url' returned dictionary, contained values are returned directly
- win_get_url - Removed deprecated 'skip_certificate_validation' parameter, use standardized 'validate_certs' instead

View file

@ -57,6 +57,19 @@ Noteworthy module changes
* The ``win_scheduled_task`` module deprecated support for specifying a trigger repetition as a list and this format
will be removed in Ansible 2.12. Instead specify the repetition as a dictionary value.
* The ``win_feature`` module has removed the deprecated ``restart_needed`` return value, use the standardised
``reboot_required`` value instead.
* The ``win_package`` module has removed the deprecated ``restart_required`` and ``exit_code`` return value, use the
standardised ``reboot_required`` and ``rc`` value instead.
* The ``win_get_url`` module has removed the deprecated ``win_get_url`` return dictionary, contained values are
returned directly.
* The ``win_get_url`` module has removed the deprecated ``skip_certificate_validation`` option, use the standardised
``validate_certs`` option instead.
Plugins
=======

View file

@ -1,49 +0,0 @@
#!powershell
# Copyright: (c) 2014, Matt Martz <matt@sivel.net>, and others
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
#Requires -Module Ansible.ModuleUtils.Legacy
$params = Parse-Args $args -supports_check_mode $true
$check_mode = Get-AnsibleParam -obj $params -name "_ansible_check_mode" -type "bool" -default $false
$path = Get-AnsibleParam -obj $params -name "path" -type "path" -failifempty $true
$state = Get-AnsibleParam -obj $params -name "state" -type "str" -default "present" -validateset "absent","present"
$creates = Get-AnsibleParam -obj $params -name "creates" -type "path"
$removes = Get-AnsibleParam -obj $params -name "removes" -type "path"
$extra_args = Get-AnsibleParam -obj $params -name "extra_args" -type "str" -default ""
$wait = Get-AnsibleParam -obj $params -name "wait" -type "bool" -default $false
$result = @{
changed = $false
}
if (-not (Test-Path -Path $path)) {
Fail-Json $result "The MSI file ($path) was not found."
}
if ($creates -and (Test-Path -Path $creates)) {
Exit-Json $result "The 'creates' file or directory ($creates) already exists."
}
if ($removes -and -not (Test-Path -Path $removes)) {
Exit-Json $result "The 'removes' file or directory ($removes) does not exist."
}
if (-not $check_mode) {
$logfile = [IO.Path]::GetTempFileName()
if ($state -eq "absent") {
Start-Process -FilePath msiexec.exe -ArgumentList "/x `"$path`" /qn /log $logfile $extra_args" -Verb Runas -Wait:$wait
} else {
Start-Process -FilePath msiexec.exe -ArgumentList "/i `"$path`" /qn /log $logfile $extra_args" -Verb Runas -Wait:$wait
}
$result.log = Get-Content $logfile | Out-String
Remove-Item $logfile
}
$result.changed = $true
Exit-Json $result

View file

@ -108,7 +108,4 @@ $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, remove in 2.8 (standardize naming to "reboot_required")
$result.restart_needed = $result.reboot_required
Exit-Json -obj $result

View file

@ -139,10 +139,4 @@ reboot_required:
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
'''

View file

@ -154,7 +154,6 @@ $url = Get-AnsibleParam -obj $params -name "url" -type "str" -failifempty $true
$dest = Get-AnsibleParam -obj $params -name "dest" -type "path" -failifempty $true
$timeout = Get-AnsibleParam -obj $params -name "timeout" -type "int" -default 10
$headers = Get-AnsibleParam -obj $params -name "headers" -type "dict" -default @{}
$skip_certificate_validation = Get-AnsibleParam -obj $params -name "skip_certificate_validation" -type "bool"
$validate_certs = Get-AnsibleParam -obj $params -name "validate_certs" -type "bool" -default $true
$url_username = Get-AnsibleParam -obj $params -name "url_username" -type "str" -aliases "username"
$url_password = Get-AnsibleParam -obj $params -name "url_password" -type "str" -aliases "password"
@ -170,11 +169,6 @@ $result = @{
dest = $dest
elapsed = 0
url = $url
# This is deprecated as of v2.4, remove in v2.8
win_get_url = @{
dest = $dest
url = $url
}
}
if (-not $use_proxy -and ($proxy_url -or $proxy_username -or $proxy_password)) {
@ -195,17 +189,11 @@ if ($url_username) {
if ($force_basic_auth) {
$credentials = [convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($url_username+":"+$url_password))
} else {
$credentials = New-Object System.Net.NetworkCredential($url_username, $url_password)
$credentials = New-Object System.Net.NetworkCredential($url_username, $url_password)
}
}
# If skip_certificate_validation was specified, use validate_certs
if ($skip_certificate_validation -ne $null) {
Add-DeprecationWarning -obj $result -message "The parameter 'skip_certificate_validation' is being replaced with 'validate_certs'" -version 2.8
$validate_certs = -not $skip_certificate_validation
}
if (-not $validate_certs) {
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = { $true }
}
@ -225,7 +213,6 @@ if (Test-Path -LiteralPath $dest -PathType Container) {
Fail-Json -obj $result -message "The destination path '$dest' does not exist, or is not visible to the current user. Ensure download destination folder exists (perhaps using win_file state=directory) before win_get_url runs."
}
$result.dest = $dest
$result.win_get_url.dest = $dest
# Enable TLS1.1/TLS1.2 if they're available but disabled (eg. .NET 4.5)
$security_protocols = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::SystemDefault

View file

@ -65,13 +65,6 @@ options:
type: bool
default: 'no'
version_added: "2.5"
skip_certificate_validation:
description:
- This option is deprecated since v2.4, please use C(validate_certs) instead.
- If C(yes), SSL certificates will not be validated. This should only be used
on personally controlled sites using self-signed certificates.
type: bool
default: 'no'
validate_certs:
description:
- If C(no), SSL certificates will not be validated. This should only be used

View file

@ -28,7 +28,6 @@ $creates_service = Get-AnsibleParam -obj $params -name "creates_service" -type "
$result = @{
changed = $false
reboot_required = $false
restart_required = $false # deprecate in 2.8
}
if ($arguments -ne $null) {
@ -100,7 +99,7 @@ namespace Ansible {
uint res = MsiOpenPackageW(msi, out MsiHandle);
if (res != 0)
return null;
int length = 256;
var buffer = new StringBuilder(length);
res = MsiGetPropertyW(MsiHandle, property, buffer, ref length);
@ -191,7 +190,7 @@ Function Get-ProgramMetadata($state, $path, $product_id, $credential, $creates_p
# Someone is using an auth that supports credential delegation, at least it will fail otherwise
$test_path = $path
}
$valid_path = Test-Path -Path $test_path -PathType Leaf
if ($valid_path -ne $true) {
$metadata.path_error = "the file at the UNC path $path cannot be reached, ensure the user_name account has access to this path or use an auth transport with credential delegation"
@ -251,7 +250,7 @@ Function Get-ProgramMetadata($state, $path, $product_id, $credential, $creates_p
if ($creates_path -ne $null) {
$path_exists = Test-Path -Path $creates_path
$metadata.installed = $path_exists
if ($creates_version -ne $null -and $path_exists -eq $true) {
if (Test-Path -Path $creates_path -PathType Leaf) {
$existing_version = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($creates_path).FileVersion
@ -299,7 +298,7 @@ Function Convert-Encoding($string) {
$program_metadata = Get-ProgramMetadata -state $state -path $path -product_id $product_id -credential $credential -creates_path $creates_path -creates_version $creates_version -creates_service $creates_service
if ($state -eq "absent") {
if ($program_metadata.installed -eq $true) {
if ($program_metadata.installed -eq $true) {
# artifacts we create that must be cleaned up
$cleanup_artifacts = @()
try {
@ -348,7 +347,7 @@ if ($state -eq "absent") {
if ($arguments -ne $null) {
$uninstall_command += " $arguments"
}
try {
$process_result = Run-Command -command $uninstall_command
} catch {
@ -362,7 +361,6 @@ if ($state -eq "absent") {
}
$result.rc = $process_result.rc
$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
@ -376,9 +374,8 @@ if ($state -eq "absent") {
if ($process_result.rc -eq 3010) {
$result.reboot_required = $true
$result.restart_required = $true
}
}
}
} finally {
# make sure we cleanup any remaining artifacts
foreach ($cleanup_artifact in $cleanup_artifacts) {
@ -400,7 +397,7 @@ if ($state -eq "absent") {
if ($program_metadata.location_type -eq [LocationType]::Unc -and $credential -ne $null) {
$file_name = Split-Path -Path $path -Leaf
$local_path = [System.IO.Path]::GetRandomFileName()
Copy-Item -Path "win_package:\$file_name" -Destination $local_path -WhatIf:$check_mode
Copy-Item -Path "win_package:\$file_name" -Destination $local_path -WhatIf:$check_mode
$cleanup_artifacts += $local_path
} elseif ($program_metadata.location_type -eq [LocationType]::Http -and $program_metadata.msi -ne $true) {
$local_path = [System.IO.Path]::GetRandomFileName()
@ -418,11 +415,11 @@ if ($state -eq "absent") {
$temp_path = [System.IO.Path]::GetTempPath()
$log_file = [System.IO.Path]::GetRandomFileName()
$log_path = Join-Path -Path $temp_path -ChildPath $log_file
$cleanup_artifacts += $log_path
$install_arguments = @("$env:windir\system32\msiexec.exe", "/i", $local_path, "/L*V", $log_path, "/qn", "/norestart")
} else {
$log_path = $null
$log_path = $null
$install_arguments = @($local_path)
}
@ -431,13 +428,13 @@ if ($state -eq "absent") {
if ($arguments -ne $null) {
$install_command += " $arguments"
}
try {
$process_result = Run-Command -command $install_command
} catch {
Fail-Json -obj $result -message "failed to run install process ($install_command): $($_.Exception.Message)"
}
if (($log_path -ne $null) -and (Test-Path -Path $log_path)) {
$log_content = Get-Content -Path $log_path | Out-String
} else {
@ -445,7 +442,6 @@ if ($state -eq "absent") {
}
$result.rc = $process_result.rc
$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
@ -459,9 +455,8 @@ if ($state -eq "absent") {
if ($process_result.rc -eq 3010) {
$result.reboot_required = $true
$result.restart_required = $true
}
}
}
} finally {
# make sure we cleanup any remaining artifacts
foreach ($cleanup_artifact in $cleanup_artifacts) {

View file

@ -215,11 +215,6 @@ EXAMPLES = r'''
'''
RETURN = r'''
exit_code:
description: See rc, this will be removed in favour of rc in Ansible 2.6.
returned: change occured
type: int
sample: 0
log:
description: The contents of the MSI log.
returned: change occured and package is an MSI
@ -236,12 +231,6 @@ reboot_required:
returned: always
type: bool
sample: True
restart_required:
description: See reboot_required, this will be removed in favour of
reboot_required in Ansible 2.6
returned: always
type: bool
sample: True
stdout:
description: The stdout stream of the package process.
returned: failure during install or uninstall

View file

@ -1 +0,0 @@
shippable/windows/group1

View file

@ -1,6 +0,0 @@
---
msi_url: https://ansible-ci-files.s3.amazonaws.com/test/integration/roles/test_win_msi/7z922-x64.msi
msi_download_path: "C:\\Program Files\\7z922-x64.msi"
msi_install_path: "C:\\Program Files\\7-Zip"
msi_product_code: "{23170F69-40C1-2702-0922-000001000000}"

View file

@ -1,70 +0,0 @@
# test code for the win_msi module
# (c) 2014, Chris Church <chris@ninemoreminutes.com>
# 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/>.
- name: use win_get_url module to download msi
win_get_url:
url: "{{msi_url}}"
dest: "{{msi_download_path}}"
register: win_get_url_result
- name: make sure msi is uninstalled
win_msi:
path: "{{msi_product_code|default(msi_download_path,true)}}"
state: absent
wait: true
ignore_errors: true
- name: install msi
win_msi:
path: "{{msi_download_path}}"
wait: true
register: win_msi_install_result
- name: check win_msi install result
assert:
that:
- "win_msi_install_result is not failed"
- "win_msi_install_result is changed"
- name: install msi again with creates argument
win_msi:
path: "{{msi_download_path}}"
wait: true
creates: "{{msi_install_path}}"
register: win_msi_install_again_result
- name: check win_msi install again result
# ignore errors because test/module is unreliable
ignore_errors: true
assert:
that:
- "win_msi_install_again_result is not failed"
- "win_msi_install_again_result is not changed"
- name: uninstall msi
win_msi:
path: "{{msi_download_path}}"
wait: true
state: absent
register: win_msi_uninstall_result
- name: check win_msi uninstall result
assert:
that:
- "win_msi_uninstall_result is not failed"
- "win_msi_uninstall_result is changed"