Removed deprecated Windows items slated for removed in 2.7 (#43231)

pull/43219/merge
Jordan Borean 6 years ago committed by GitHub
parent 5eb47066e3
commit 2c9cbae3f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -108,6 +108,19 @@ Noteworthy module changes
escape any double quotes in the value. This is no longer required and the escaping may cause further
issues.
* The ``win_uri`` module has removed the deprecated option ``use_basic_parsing``, since Ansible 2.5 this option did
nothing
* The ``win_scheduled_task`` module has removed the following deprecated options:
* ``executable``, use ``path`` in an actions entry instead
* ``argument``, use ``arguments`` in an actions entry instead
* ``store_password``, set ``logon_type: password`` instead
* ``days_of_week``, use ``monthlydow`` in a triggers entry instead
* ``frequency``, use ``type``, in a triggers entry instead
* ``time``, use ``start_boundary`` in a triggers entry instead
Plugins
=======

@ -62,18 +62,6 @@ $start_when_available = Get-AnsibleParam -obj $params -name "start_when_availabl
$stop_if_going_on_batteries = Get-AnsibleParam -obj $params -name "stop_if_going_on_batteries" -type "bool"
$wake_to_run = Get-AnsibleParam -obj $params -name "wake_to_run" -type "bool"
# deprecated action arguments - use actions instead
$old_arguments = Get-AnsibleParam -obj $params -name "arguments" -type "str" -aliases "argument"
$old_executable = Get-AnsibleParam -obj $params -name "executable" -type "path" -failifempty ($old_arguments -ne $null) -aliases "execute"
# deprecated principal arguments - use logon_type instead
$store_password = Get-AnsibleParam -obj $params -name "store_password" -type "bool"
# deprecated trigger arguments - use triggers instead
$old_days_of_week = Get-AnsibleParam -obj $params -name "days_of_week" -type "list"
$old_frequency = Get-AnsibleParam -obj $params -name "frequency" -type "str"
$old_time = Get-AnsibleParam -obj $params -name "time" -type "str"
$result = @{
changed = $false
}
@ -707,35 +695,11 @@ if ($group) {
$group_sid = Convert-ToSID -account_name $group
}
# Convert the older arguments to the newer format if required
if ($old_executable -ne $null) {
Add-DeprecationWarning -obj $result -message "executable option is deprecated, please use the actions list option instead" -version 2.7
if ($actions -ne $null) {
Fail-Json -obj $result -message "actions and executable are mutually exclusive, use actions by itself instead"
}
$new_action = @{ path = $old_executable }
if ($old_arguments -ne $null) {
Add-DeprecationWarning -obj $result -message "arguments option is deprecated, please use the actions list option instead" -version 2.7
$new_action.arguments = $old_arguments
}
$actions = @($new_action)
}
# validate store_password and logon_type
if ($logon_type -ne $null) {
$full_enum_name = "TASK_LOGON_$($logon_type.ToUpper())"
$logon_type = [TASK_LOGON_TYPE]::$full_enum_name
}
if ($store_password -ne $null) {
Add-DeprecationWarning -obj $result -message "store_password option is deprecated, please use logon_type: password instead" -version 2.7
if ($logon_type -ne $null) {
Fail-Json -obj $result -message "logon_type and store_password are mutually exclusive, use logon_type=password instead"
}
if ($store_password -eq $true -and $password -ne $null) {
$logon_type = [TASK_LOGON_TYPE]::TASK_LOGON_PASSWORD
}
}
# now validate the logon_type option with the other parameters
if ($username -ne $null -and $group -ne $null) {
@ -778,47 +742,6 @@ for ($i = 0; $i -lt $actions.Count; $i++) {
$actions[$i] = $action
}
# convert deprecated trigger args to new format
$deprecated_trigger = $null
if ($old_frequency -ne $null) {
# once, daily, weekly
Add-DeprecationWarning -obj $result -message "" -version 2.7
if ($triggers.Count -eq 0) {
$deprecated_trigger = @{type = $null}
switch ($frequency) {
once { $deprecated_trigger.type = [TASK_TRIGGER_TYPE2]::TASK_TRIGGER_TIME }
daily { $deprecated_trigger.type = [TASK_TRIGGER_TYPE2]::TASK_TRIGGER_DAILY }
weekly { $deprecated_trigger.type = [TASK_TRIGGER_TYPE2]::TASK_TRIGGER_WEEKLY }
}
} else {
Add-Warning -obj $result -message "the trigger list is already specified, ignoring the frequency option as it is deprecated"
}
}
if ($old_days_of_week -ne $null) {
Add-DeprecationWarning -obj $result -message "days_of_week is deprecated, use the triggers list with 'monthlydow' type" -version 2.7
if ($triggers.Count -eq 0) {
$deprecated_trigger.days_of_week = $old_days_of_week
} else {
Add-Warning -obj $result -message "the trigger list is already specified, ignoring the days_of_week option as it is deprecated"
}
}
if ($old_time -ne $null) {
Add-DeprecationWarning -obj $result -message "old_time is deprecated, use the triggers list to specify the 'start_boundary'" -version 2.7
if ($triggers.Count -eq 0) {
try {
$old_time_cast = [datetime]$old_time
} catch [System.InvalidCastException] {
Fail-Json -obj $result -message "failed to convert time '$old_time' to the DateTime format"
}
$deprecated_trigger.start_boundary = ($old_time_cast | Get-Date -Format s)
} else {
Add-Warning -obj $result -message "the trigger list is already specified, ignoring the time option as it is deprecated"
}
}
if ($deprecated_trigger -ne $null) {
$triggers += $deprecated_trgger
}
# convert and validate the triggers - and convert PSCustomObject to Hashtable
for ($i = 0; $i -lt $triggers.Count; $i++) {
$trigger = ConvertTo-HashtableFromPsCustomObject -object $triggers[$i]

@ -66,20 +66,6 @@ options:
description:
- The working directory to run the executable from.
version_added: '2.5'
arguments:
description:
- Arguments to provide for a scheduled task action.
- DEPRECATED since 2.5, use the C(actions) option instead to specify a list
of actions to run.
- Will be removed in 2.7.
aliases: [ argument ]
executable:
description:
- The path to the executable to run for a scheduled task action.
- DEPRECATED since 2.5, use the C(actions) option instead to specify a list
of actions to run.
- Will be removed in 2.7.
type: path
# Trigger options
triggers:
@ -204,28 +190,6 @@ options:
- C(interval) is the amount of time between earch restart of the task and is written in the ISO 8601 Duration format C(P[n]Y[n]M[n]DT[n]H[n]M[n]S).
- C(stop_at_duration_end) is a boolean value that indicates if a running instance of the task is stopped at the end of the repetition pattern.
version_added: '2.5'
days_of_week:
description:
- Days of the week to run a weekly task.
- Specify a list or comma separate days in the full version, e.g. monday
instead of mon.
- DEPRECATED since 2.5, use the C(triggers) option list with the type of
C(monthlydow) or C(weekly).
- Will be removed in 2.7.
type: list
frequency:
description:
- The frequency of the task to run.
- DEPRECATED since 2.5, use the C(triggers) option list and specify the
type based on the frequency required.
- Will be removed in 2.7.
choices: [ daily, once, weekly ]
time:
description:
- The start time to execute the scheduled task.
- DEPRECATED since 2.5, use the C(triggers) option list and use the
C(start_boundary) option to set the start time.
- Will be removed in 2.7.
# Principal options
display_name:
@ -282,16 +246,6 @@ options:
type: bool
default: 'yes'
version_added: '2.5'
store_password:
description:
- Whether to store the password for the user running the task.
- If C(no), the task will only have access to local resources.
- DEPRECATED since 2.5, use C(logon_type=password) to set whether to store
the password for the task.
- Will be removed in 2.7.
type: bool
default: 'yes'
version_added: '2.4'
# RegistrationInfo options
author:

@ -32,7 +32,6 @@ $maximum_redirection = Get-AnsibleParam -obj $params -name "maximum_redirection"
$return_content = Get-AnsibleParam -obj $params -name "return_content" -type "bool" -default $false
$status_code = Get-AnsibleParam -obj $params -name "status_code" -type "list" -default @(200)
$timeout = Get-AnsibleParam -obj $params -name "timeout" -type "int" -default 30
$use_basic_parsing = Get-AnsibleParam -obj $params -name "use_basic_parsing" -type "bool"
$validate_certs = Get-AnsibleParam -obj $params -name "validate_certs" -type "bool" -default $true
$client_cert = Get-AnsibleParam -obj $params -name "client_cert" -type "path"
$client_cert_password = Get-AnsibleParam -obj $params -name "client_cert_password" -type "str"
@ -52,10 +51,6 @@ if ($removes -and -not (Test-AnsiblePath -Path $removes)) {
Exit-Json -obj $result -message "The 'removes' file or directory ($removes) does not exist."
}
if ($use_basic_parsing) {
Add-DeprecationWarning -obj $result -message "Since Ansible 2.5, use_basic_parsing does not change any behaviour, this option will be removed" -version 2.7
}
if ($status_code) {
$status_code = foreach ($code in $status_code) {
try {

@ -61,17 +61,6 @@ options:
description:
- Extra headers to set on the request, see the examples for more details on
how to set this.
use_basic_parsing:
description:
- As of Ansible 2.5, this option is no longer valid and cannot be changed from C(yes), this option will be removed
in Ansible 2.7.
- Before Ansible 2.5, this module relies upon 'Invoke-WebRequest', which by default uses the Internet Explorer Engine
to parse a webpage.
- There's an edge-case where if a user hasn't run IE before, this will fail.
- The only advantage to using the Internet Explorer praser is that you can traverse the DOM in a powershell script.
- That isn't useful for Ansible, so by default we toggle 'UseBasicParsing'. However, you can toggle that off here.
type: bool
default: 'yes'
creates:
description:
- A filename, when it already exists, this step will be skipped.

@ -3,20 +3,6 @@
include_tasks: clean.yml
- block:
# old tests, remove once new code is considered stable
- name: Test in normal mode
import_tasks: tests.yml
vars:
in_check_mode: no
- name: Test in check-mode
import_tasks: tests.yml
vars:
in_check_mode: yes
check_mode: yes
- include_tasks: clean.yml
- name: Test failure scenarios
include_tasks: failures.yml

@ -1,319 +0,0 @@
# these are the older tests that test out the deprecated args, keep here until
# the new changes are more bedded down
---
- name: Remove potentially leftover scheduled task
win_scheduled_task: &wst_absent
name: Ansible Test
state: absent
- name: Add scheduled task
win_scheduled_task: &wst_present
name: Ansible Test
executable: dir.exe
arguments: C:\Windows\Temp\
frequency: once
time: 5pm
user: SYSTEM
register: add_scheduled_task
- name: Test add_scheduled_task
assert:
that:
- add_scheduled_task.changed == true
- name: Add scheduled task (again)
win_scheduled_task: *wst_present
register: add_scheduled_task_again
- name: Test add_scheduled_task_again (normal mode)
assert:
that:
- add_scheduled_task_again.changed == false
when: not in_check_mode
- name: Test add_scheduled_task_again (check-mode)
assert:
that:
- add_scheduled_task_again.changed == true
when: in_check_mode
# FIXME: The below tasks should not require all options
# See: https://github.com/ansible/ansible/issues/19279
- name: Run tests for normal mode only (expects scheduled task)
when: not in_check_mode
block:
- name: Disable scheduled task
win_scheduled_task:
<<: *wst_present
enabled: no
register: disable_scheduled_task
- name: Test disable_scheduled_task
assert:
that:
- disable_scheduled_task.changed == true
- name: Disable scheduled task (again)
win_scheduled_task:
<<: *wst_present
enabled: no
register: disable_scheduled_task_again
- name: Test disable_scheduled_task_again
assert:
that:
- disable_scheduled_task_again.changed == false
- name: Enable scheduled task
win_scheduled_task:
<<: *wst_present
enabled: yes
register: enable_scheduled_task
- assert:
that:
- enable_scheduled_task.changed == true
- name: Enable scheduled task (again)
win_scheduled_task:
<<: *wst_present
enabled: yes
register: enable_scheduled_task_again
- assert:
that:
- enable_scheduled_task_again.changed == false
- name: Remove scheduled task
win_scheduled_task: *wst_absent
register: remove_scheduled_task
- name: Test remove_scheduled_task (normal mode)
assert:
that:
- remove_scheduled_task.changed == true
when: not in_check_mode
- name: Test remove_scheduled_task (check-mode)
assert:
that:
- remove_scheduled_task.changed == false
when: in_check_mode
- name: Remove scheduled task (again)
win_scheduled_task: *wst_absent
register: remove_scheduled_task_again
- name: Test remove_scheduled_task_again
assert:
that:
- remove_scheduled_task_again.changed == false
# Test scheduled task path creation and removal
- name: Remove potentially leftover new path task 1
win_scheduled_task: &wstp1_absent
name: Ansible Test New Path 1
path: \non_existent_path\
state: absent
- name: Remove potentially leftover new path task 2
win_scheduled_task: &wstp2_absent
name: Ansible Test New Path 2
path: \non_existent_path\
state: absent
- name: Add scheduled task new path 1
win_scheduled_task: &wstp1_present
name: Ansible Test New Path 1
description: A test of functionality
executable: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
arguments: -ExecutionPolicy Unrestricted -NonInteractive -File C:\TestDir\Test.ps1
time: "9:45pm"
path: \non_existent_path\
frequency: once
state: present
enabled: yes
user: SYSTEM
register: add_scheduled_task_new_path_1
- name: Test add_scheduled_task_new_path_1
assert:
that:
- add_scheduled_task_new_path_1 is changed
- name: Add scheduled task new path 2
win_scheduled_task: &wstp2_present
<<: *wstp1_present
name: Ansible Test New Path 2
register: add_scheduled_task_new_path_2
- name: Test add_scheduled_task_new_path_2 (normal mode)
assert:
that:
- add_scheduled_task_new_path_2 is changed
when: not in_check_mode
- name: Test add_scheduled_task_new_path_2 (check-mode)
assert:
that:
- add_scheduled_task_new_path_2 is changed
when: in_check_mode
- name: Remove scheduled task new path 2
win_scheduled_task: *wstp2_absent
register: remove_scheduled_task_new_path_2
- name: Test remove_scheduled_task_new_path_2 (normal mode)
assert:
that:
- remove_scheduled_task_new_path_2 is changed
when: not in_check_mode
- name: Test remove_scheduled_task_new_path_2 (check-mode)
assert:
that:
- remove_scheduled_task_new_path_2 is not changed
when: in_check_mode
- name: Remove scheduled task new path 1
win_scheduled_task: *wstp1_absent
register: remove_scheduled_task_new_path_1
- name: Test remove_scheduled_task_new_path_1 (normal mode)
assert:
that:
- remove_scheduled_task_new_path_1 is changed
when: not in_check_mode
- name: Test remove_scheduled_task_new_path_1 (check-mode)
assert:
that:
- remove_scheduled_task_new_path_1 is not changed
when: in_check_mode
# Test scheduled task RunAs and RunLevel options
- name: Remove potentially leftover run options task 1
win_scheduled_task: &wstr1_absent
name: Ansible Test Run Options 1
state: absent
- name: Add scheduled task run options 1
win_scheduled_task: &wstr1_present
name: Ansible Test Run Options 1
description: A test of run options functionality
executable: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
arguments: -ExecutionPolicy Unrestricted -NonInteractive -File C:\TestDir\Test.ps1
time: "6pm"
frequency: once
state: present
enabled: yes
user: SYSTEM
register: add_scheduled_task_run_options_1
- name: Test add_scheduled_task_run_options_1
assert:
that:
- add_scheduled_task_run_options_1.changed == true
- name: Execute run options tests for normal mode only (expects scheduled task)
when: not in_check_mode
block:
- name: Change scheduled task run options user
win_scheduled_task:
<<: *wstr1_present
user: NETWORK SERVICE
register: change_scheduled_task_run_options_user
- name: Test change_scheduled_task_run_options_user
assert:
that:
- change_scheduled_task_run_options_user.changed == true
- name: Change scheduled task run options user (again)
win_scheduled_task:
<<: *wstr1_present
user: NETWORK SERVICE
register: change_scheduled_task_run_options_user_again
- name: Test change_scheduled_task_run_options_user_again
assert:
that:
- change_scheduled_task_run_options_user_again.changed == false
- name: Change scheduled task run options run level
win_scheduled_task:
<<: *wstr1_present
user: NETWORK SERVICE
runlevel: highest
register: change_scheduled_task_run_options_runlevel
- name: Test change_scheduled_task_run_options_runlevel
assert:
that:
- change_scheduled_task_run_options_runlevel.changed == true
- name: Change scheduled task run options run level (again)
win_scheduled_task:
<<: *wstr1_present
user: NETWORK SERVICE
runlevel: highest
register: change_scheduled_task_run_options_runlevel_again
- name: Test change_scheduled_task_run_options_runlevel_again
assert:
that:
- change_scheduled_task_run_options_runlevel_again.changed == false
# Should ignore change as account being tested is a built-in service account
- name: Change scheduled task run options store password
win_scheduled_task:
<<: *wstr1_present
user: NETWORK SERVICE
runlevel: highest
store_password: no
register: change_scheduled_task_run_options_store_password
- name: Test change_scheduled_task_run_options_store_password
assert:
that:
- change_scheduled_task_run_options_store_password.changed == false
- name: Remove scheduled task run options 1
win_scheduled_task: *wstr1_absent
register: remove_scheduled_task_run_options_1
- name: Test remove_scheduled_task_run_options_1 (normal mode)
assert:
that:
- remove_scheduled_task_run_options_1.changed == true
when: not in_check_mode
- name: Test remove_scheduled_task_run_options_1 (check-mode)
assert:
that:
- remove_scheduled_task_run_options_1.changed == false
when: in_check_mode
Loading…
Cancel
Save