mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-23 04:24:00 -07:00
win_scheduled_task: rewrite (#28995)
* win_scheduled_task: rewrite for additionality functionality and bug fixes * fixes for docs and os version differences * started with the testing * doc fix * added more tests * added principals tests * finished tests for win_scheduled_task rewrite * feedback from PR * change to fail when both new and deprecated args are set * change diff variable to match new standard and update doc sentance
This commit is contained in:
parent
31daeb4b85
commit
838f39e76a
11 changed files with 3547 additions and 397 deletions
16
test/integration/targets/win_scheduled_task/tasks/clean.yml
Normal file
16
test/integration/targets/win_scheduled_task/tasks/clean.yml
Normal file
|
@ -0,0 +1,16 @@
|
|||
# cleans up each test to ensure a blank slate
|
||||
---
|
||||
- win_scheduled_task:
|
||||
name: '{{item.name}}'
|
||||
path: '{{item.path|default(omit)}}'
|
||||
state: absent
|
||||
with_items:
|
||||
- name: Task # old tests
|
||||
path: \Path
|
||||
- name: '{{test_scheduled_task_name}}'
|
||||
- name: '{{test_scheduled_task_name}}'
|
||||
path: '{{test_scheduled_task_path}}'
|
||||
|
||||
- win_user:
|
||||
name: '{{test_scheduled_task_user}}'
|
||||
state: absent
|
123
test/integration/targets/win_scheduled_task/tasks/failures.yml
Normal file
123
test/integration/targets/win_scheduled_task/tasks/failures.yml
Normal file
|
@ -0,0 +1,123 @@
|
|||
# test out the known failure cases to ensure we have decent error messages
|
||||
---
|
||||
- name: fail create task without an action
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
register: fail_create_without_action
|
||||
failed_when: fail_create_without_action.msg != 'cannot create a task with no actions, set at least one action with a path to an executable'
|
||||
|
||||
- name: fail both username and group are set
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
username: '{{ansible_user}}'
|
||||
group: '{{ansible_user}}'
|
||||
register: fail_username_and_group
|
||||
failed_when: fail_username_and_group.msg != 'username and group can not be set at the same time'
|
||||
|
||||
- name: fail logon type password but no password set
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
logon_type: password
|
||||
register: fail_lt_password_not_set
|
||||
failed_when: fail_lt_password_not_set.msg != 'password must be set when logon_type=password'
|
||||
|
||||
- name: fail logon type s4u but no password set
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
logon_type: s4u
|
||||
register: fail_lt_s4u_not_set
|
||||
failed_when: fail_lt_s4u_not_set.msg != 'password must be set when logon_type=s4u'
|
||||
|
||||
- name: fail logon type group but no group set
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
logon_type: group
|
||||
register: fail_lt_group_not_set
|
||||
failed_when: fail_lt_group_not_set.msg != 'group must be set when logon_type=group'
|
||||
|
||||
- name: fail logon type service but non service user set
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
logon_type: service_account
|
||||
username: '{{ansible_user}}'
|
||||
register: fail_lt_service_invalid_user
|
||||
failed_when: fail_lt_service_invalid_user.msg != 'username must be SYSTEM, LOCAL SERVICE or NETWORK SERVICE when logon_type=service_account'
|
||||
|
||||
- name: fail trigger with no type
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
triggers:
|
||||
- delay: test
|
||||
register: fail_trigger_no_type
|
||||
failed_when: fail_trigger_no_type.msg != "a trigger entry must contain a key 'type' with a value of 'event', 'time', 'daily', 'weekly', 'monthly', 'monthlydow', 'idle', 'registration', 'boot', 'logon', 'session_state_change'"
|
||||
|
||||
- name: fail trigger with datetime in incorrect format
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
triggers:
|
||||
- type: time
|
||||
start_boundary: fake
|
||||
register: fail_trigger_invalid_datetime
|
||||
failed_when: fail_trigger_invalid_datetime.msg != "trigger option 'start_boundary' must be in the format 'YYYY-MM-DDThh:mm:ss' format but was 'fake'"
|
||||
|
||||
- name: fail trigger with duration in incorrect format
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
triggers:
|
||||
- type: boot
|
||||
execution_time_limit: fake
|
||||
register: fail_trigger_invalid_duration
|
||||
failed_when: fail_trigger_invalid_duration.msg != "trigger option 'execution_time_limit' must be in the XML duration format but was 'fake'"
|
||||
|
||||
- name: fail trigger option invalid day of the week
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
triggers:
|
||||
- type: weekly
|
||||
start_boundary: '2000-01-01T00:00:01'
|
||||
days_of_week: fakeday
|
||||
register: fail_trigger_invalid_day_of_week
|
||||
failed_when: fail_trigger_invalid_day_of_week.msg != "invalid day of week 'fakeday', check the spelling matches the full day name"
|
||||
|
||||
- name: fail trigger option invalid day of the month
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
triggers:
|
||||
- type: monthly
|
||||
start_boundary: '2000-01-01T00:00:01'
|
||||
days_of_month: 35
|
||||
register: fail_trigger_invalid_day_of_month
|
||||
failed_when: fail_trigger_invalid_day_of_month.msg != "invalid day of month '35', please specify numbers from 1-31"
|
||||
|
||||
- name: fail trigger option invalid week of the month
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
triggers:
|
||||
- type: monthlydow
|
||||
start_boundary: '2000-01-01T00:00:01'
|
||||
weeks_of_month: 5
|
||||
register: fail_trigger_invalid_week_of_month
|
||||
failed_when: fail_trigger_invalid_week_of_month.msg != "invalid week of month '5', please specify weeks from 1-4"
|
||||
|
||||
- name: fail trigger option invalid month of the year
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
triggers:
|
||||
- type: monthlydow
|
||||
start_boundary: '2000-01-01T00:00:01'
|
||||
months_of_year: fakemonth
|
||||
register: fail_trigger_invalid_month_of_year
|
||||
failed_when: fail_trigger_invalid_month_of_year.msg != "invalid month name 'fakemonth', please specify full month name"
|
|
@ -1,21 +1,38 @@
|
|||
# NOTE: The win_scheduled_task module only works on Win2012+
|
||||
|
||||
- name: Test Windows capabilities
|
||||
raw: Get-Command New-ScheduledTask -ErrorAction SilentlyContinue; return $?
|
||||
failed_when: no
|
||||
register: new_scheduledtask
|
||||
|
||||
- name: Only run tests when Windows is capable
|
||||
when: new_scheduledtask.rc == 0
|
||||
block:
|
||||
---
|
||||
- name: remove test tasks before test
|
||||
include_tasks: clean.yml
|
||||
|
||||
- block:
|
||||
# old tests, remove once new code is considered stable
|
||||
- name: Test in normal mode
|
||||
include: tests.yml
|
||||
include_tasks: tests.yml
|
||||
vars:
|
||||
in_check_mode: no
|
||||
|
||||
- name: Test in check-mode
|
||||
include: tests.yml
|
||||
include_tasks: tests.yml
|
||||
vars:
|
||||
in_check_mode: yes
|
||||
check_mode: yes
|
||||
|
||||
- include_tasks: clean.yml
|
||||
|
||||
- name: Test failure scenarios
|
||||
include: failures.yml
|
||||
|
||||
- name: Test normal scenarios
|
||||
include_tasks: new_tests.yml
|
||||
|
||||
- include_tasks: clean.yml
|
||||
|
||||
- name: Test principals
|
||||
include_tasks: principals.yml
|
||||
|
||||
- include_tasks: clean.yml
|
||||
|
||||
- name: Test triggers
|
||||
include_tasks: triggers.yml
|
||||
|
||||
always:
|
||||
- name: remove test tasks after test
|
||||
include_tasks: clean.yml
|
||||
|
|
440
test/integration/targets/win_scheduled_task/tasks/new_tests.yml
Normal file
440
test/integration/targets/win_scheduled_task/tasks/new_tests.yml
Normal file
|
@ -0,0 +1,440 @@
|
|||
---
|
||||
- name: create task (check mode)
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
actions:
|
||||
- path: cmd.exe
|
||||
arguments: /c echo hi
|
||||
description: Original Description
|
||||
register: create_task_check
|
||||
check_mode: yes
|
||||
|
||||
- name: get result of create task (check mode)
|
||||
test_task_stat:
|
||||
path: \
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
register: create_task_result_check
|
||||
|
||||
- name: assert results of create task (check mode)
|
||||
assert:
|
||||
that:
|
||||
- create_task_check|changed
|
||||
- create_task_result_check.task_exists == False
|
||||
|
||||
- name: create task
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
actions:
|
||||
- path: cmd.exe
|
||||
arguments: /c echo hi
|
||||
description: Original Description
|
||||
register: create_task
|
||||
|
||||
- name: get result of create task
|
||||
test_task_stat:
|
||||
path: \
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
register: create_task_result
|
||||
|
||||
- name: assert results of create task
|
||||
assert:
|
||||
that:
|
||||
- create_task|changed
|
||||
- create_task_result.task_exists == True
|
||||
- create_task_result.task.actions|count == 1
|
||||
- create_task_result.task.actions[0].Path == "cmd.exe"
|
||||
- create_task_result.task.actions[0].Arguments == "/c echo hi"
|
||||
- create_task_result.task.actions[0].WorkingDirectory == None
|
||||
- create_task_result.task.registration_info.Description == "Original Description"
|
||||
- create_task_result.task.triggers|count == 0
|
||||
|
||||
- name: create task (idempotent)
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
actions:
|
||||
- path: cmd.exe
|
||||
arguments: /c echo hi
|
||||
description: Original Description
|
||||
register: create_task_again
|
||||
|
||||
- name: assert results of create task (idempotent)
|
||||
assert:
|
||||
that:
|
||||
- not create_task_again|changed
|
||||
|
||||
- name: change task (check mode)
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
author: Cow Inc.
|
||||
description: Test for Ansible
|
||||
allow_demand_start: no
|
||||
restart_count: 5
|
||||
restart_interval: PT2H5M
|
||||
register: change_task_check
|
||||
check_mode: yes
|
||||
|
||||
- name: get result of change task (check mode)
|
||||
test_task_stat:
|
||||
path: \
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
register: change_task_result_check
|
||||
|
||||
- name: assert results of change task (check mode)
|
||||
assert:
|
||||
that:
|
||||
- change_task_check|changed
|
||||
- change_task_result_check.task.actions|count == 1
|
||||
- change_task_result_check.task.registration_info.Author == None
|
||||
- change_task_result_check.task.registration_info.Description == "Original Description"
|
||||
- change_task_result_check.task.settings.AllowDemandStart == true
|
||||
- change_task_result_check.task.settings.RestartCount == 0
|
||||
- change_task_result_check.task.settings.RestartInterval == None
|
||||
|
||||
- name: change task
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
author: Cow Inc.
|
||||
description: Test for Ansible
|
||||
allow_demand_start: no
|
||||
restart_count: 5
|
||||
restart_interval: PT1M
|
||||
register: change_task
|
||||
|
||||
- name: get result of change task
|
||||
test_task_stat:
|
||||
path: \
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
register: change_task_result
|
||||
|
||||
- name: assert results of change task
|
||||
assert:
|
||||
that:
|
||||
- change_task|changed
|
||||
- change_task_result.task.actions|count == 1
|
||||
- change_task_result.task.registration_info.Author == "Cow Inc."
|
||||
- change_task_result.task.registration_info.Description == "Test for Ansible"
|
||||
- change_task_result.task.settings.AllowDemandStart == false
|
||||
- change_task_result.task.settings.RestartCount == 5
|
||||
- change_task_result.task.settings.RestartInterval == "PT1M"
|
||||
|
||||
- name: change task (idempotent)
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
author: Cow Inc.
|
||||
description: Test for Ansible
|
||||
allow_demand_start: no
|
||||
restart_count: 5
|
||||
restart_interval: PT1M
|
||||
register: change_task_again
|
||||
|
||||
- name: assert results of change task (idempotent)
|
||||
assert:
|
||||
that:
|
||||
- not change_task_again|changed
|
||||
|
||||
- name: add task action (check mode)
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
actions:
|
||||
- path: cmd.exe
|
||||
arguments: /c echo hi
|
||||
- path: powershell.exe
|
||||
arguments: -File C:\ansible\script.ps1
|
||||
working_directory: C:\ansible
|
||||
register: add_task_action_check
|
||||
check_mode: yes
|
||||
|
||||
- name: get result of add task action (check mode)
|
||||
test_task_stat:
|
||||
path: \
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
register: add_task_action_result_check
|
||||
|
||||
- name: assert results of add task action (check mode)
|
||||
assert:
|
||||
that:
|
||||
- add_task_action_check|changed
|
||||
- add_task_action_result_check.task.actions|count == 1
|
||||
- add_task_action_result_check.task.actions[0].Path == "cmd.exe"
|
||||
- add_task_action_result_check.task.actions[0].Arguments == "/c echo hi"
|
||||
- add_task_action_result_check.task.actions[0].WorkingDirectory == None
|
||||
|
||||
- name: add task action
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
actions:
|
||||
- path: cmd.exe
|
||||
arguments: /c echo hi
|
||||
- path: powershell.exe
|
||||
arguments: -File C:\ansible\script.ps1
|
||||
working_directory: C:\ansible
|
||||
register: add_task_action
|
||||
|
||||
- name: get result of add task action
|
||||
test_task_stat:
|
||||
path: \
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
register: add_task_action_result
|
||||
|
||||
- name: assert results of add task action
|
||||
assert:
|
||||
that:
|
||||
- add_task_action|changed
|
||||
- add_task_action_result.task.actions|count == 2
|
||||
- add_task_action_result.task.actions[0].Path == "cmd.exe"
|
||||
- add_task_action_result.task.actions[0].Arguments == "/c echo hi"
|
||||
- add_task_action_result.task.actions[0].WorkingDirectory == None
|
||||
- add_task_action_result.task.actions[1].Path == "powershell.exe"
|
||||
- add_task_action_result.task.actions[1].Arguments == "-File C:\\ansible\\script.ps1"
|
||||
- add_task_action_result.task.actions[1].WorkingDirectory == "C:\\ansible"
|
||||
|
||||
- name: add task action (idempotent)
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
actions:
|
||||
- path: cmd.exe
|
||||
arguments: /c echo hi
|
||||
- path: powershell.exe
|
||||
arguments: -File C:\ansible\script.ps1
|
||||
working_directory: C:\ansible
|
||||
register: add_task_action_again
|
||||
|
||||
- name: assert results of add task action (idempotent)
|
||||
assert:
|
||||
that:
|
||||
- not add_task_action_again|changed
|
||||
|
||||
- name: remove task action (check mode)
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
actions:
|
||||
- path: powershell.exe
|
||||
arguments: -File C:\ansible\script.ps1
|
||||
working_directory: C:\ansible
|
||||
register: remove_task_action_check
|
||||
check_mode: yes
|
||||
|
||||
- name: get result of remove task action (check mode)
|
||||
test_task_stat:
|
||||
path: \
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
register: remove_task_action_result_check
|
||||
|
||||
- name: assert results of remove task action (check mode)
|
||||
assert:
|
||||
that:
|
||||
- remove_task_action_check|changed
|
||||
- remove_task_action_result_check.task.actions|count == 2
|
||||
- remove_task_action_result_check.task.actions[0].Path == "cmd.exe"
|
||||
- remove_task_action_result_check.task.actions[0].Arguments == "/c echo hi"
|
||||
- remove_task_action_result_check.task.actions[0].WorkingDirectory == None
|
||||
- remove_task_action_result_check.task.actions[1].Path == "powershell.exe"
|
||||
- remove_task_action_result_check.task.actions[1].Arguments == "-File C:\\ansible\\script.ps1"
|
||||
- remove_task_action_result_check.task.actions[1].WorkingDirectory == "C:\\ansible"
|
||||
|
||||
- name: remove task action
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
actions:
|
||||
- path: powershell.exe
|
||||
arguments: -File C:\ansible\script.ps1
|
||||
working_directory: C:\ansible
|
||||
register: remove_task_action
|
||||
|
||||
- name: get result of remove task action
|
||||
test_task_stat:
|
||||
path: \
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
register: remove_task_action_result
|
||||
|
||||
- name: assert results of remove task action
|
||||
assert:
|
||||
that:
|
||||
- remove_task_action|changed
|
||||
- remove_task_action_result.task.actions|count == 1
|
||||
- remove_task_action_result.task.actions[0].Path == "powershell.exe"
|
||||
- remove_task_action_result.task.actions[0].Arguments == "-File C:\\ansible\\script.ps1"
|
||||
- remove_task_action_result.task.actions[0].WorkingDirectory == "C:\\ansible"
|
||||
|
||||
- name: remove task action (idempontent)
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
actions:
|
||||
- path: powershell.exe
|
||||
arguments: -File C:\ansible\script.ps1
|
||||
working_directory: C:\ansible
|
||||
register: remove_task_action_again
|
||||
|
||||
- name: assert results of remove task action (idempotent)
|
||||
assert:
|
||||
that:
|
||||
- not remove_task_action_again|changed
|
||||
|
||||
- name: remove task (check mode)
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: absent
|
||||
register: remove_task_check
|
||||
check_mode: yes
|
||||
|
||||
- name: get result of remove task (check mode)
|
||||
test_task_stat:
|
||||
path: \
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
register: remove_task_result_check
|
||||
|
||||
- name: assert results of remove task (check mode)
|
||||
assert:
|
||||
that:
|
||||
- remove_task_check|changed
|
||||
- remove_task_result_check.task_exists == True
|
||||
|
||||
- name: remove task
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: absent
|
||||
register: remove_task
|
||||
|
||||
- name: get result of remove task
|
||||
test_task_stat:
|
||||
path: \
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
register: remove_task_result
|
||||
|
||||
- name: assert results of remove task
|
||||
assert:
|
||||
that:
|
||||
- remove_task|changed
|
||||
- remove_task_result.task_exists == False
|
||||
|
||||
- name: remove task (idempotent)
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: absent
|
||||
register: remove_task_again
|
||||
|
||||
- name: assert results of remove task (idempotent)
|
||||
assert:
|
||||
that:
|
||||
- not remove_task_again|changed
|
||||
|
||||
- name: create sole task in folder (check mode)
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
path: '{{test_scheduled_task_path}}'
|
||||
actions:
|
||||
- path: cmd.exe
|
||||
register: create_sole_task_check
|
||||
check_mode: yes
|
||||
|
||||
- name: get result of create sole task in folder (check mode)
|
||||
test_task_stat:
|
||||
path: '{{test_scheduled_task_path}}'
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
register: create_sole_task_result_check
|
||||
|
||||
- name: assert results of create sole task in folder (check mode)
|
||||
assert:
|
||||
that:
|
||||
- create_sole_task_check|changed
|
||||
- create_sole_task_result_check.folder_exists == False
|
||||
- create_sole_task_result_check.task_exists == False
|
||||
|
||||
- name: create sole task in folder
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
path: '{{test_scheduled_task_path}}'
|
||||
actions:
|
||||
- path: cmd.exe
|
||||
register: create_sole_task
|
||||
|
||||
- name: get result of create sole task in folder
|
||||
test_task_stat:
|
||||
path: '{{test_scheduled_task_path}}'
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
register: create_sole_task_result
|
||||
|
||||
- name: assert results of create sole task in folder
|
||||
assert:
|
||||
that:
|
||||
- create_sole_task|changed
|
||||
- create_sole_task_result.folder_exists == True
|
||||
- create_sole_task_result.task_exists == True
|
||||
|
||||
- name: create sole task in folder (idempotent)
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
path: '{{test_scheduled_task_path}}'
|
||||
actions:
|
||||
- path: cmd.exe
|
||||
register: create_sole_task_again
|
||||
|
||||
- name: assert results of create sole task in folder (idempotent)
|
||||
assert:
|
||||
that:
|
||||
- not create_sole_task_again|changed
|
||||
|
||||
- name: remove sole task in folder (check mode)
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
path: '{{test_scheduled_task_path}}'
|
||||
state: absent
|
||||
register: remove_sole_task_check
|
||||
check_mode: yes
|
||||
|
||||
- name: get result of remove sole task in folder (check mode)
|
||||
test_task_stat:
|
||||
path: '{{test_scheduled_task_path}}'
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
register: remove_sole_task_result_check
|
||||
|
||||
- name: assert results of remove sole task in folder (check mode)
|
||||
assert:
|
||||
that:
|
||||
- remove_sole_task_check|changed
|
||||
- remove_sole_task_result_check.folder_exists == True
|
||||
- remove_sole_task_result_check.task_exists == True
|
||||
|
||||
- name: remove sole task in folder
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
path: '{{test_scheduled_task_path}}'
|
||||
state: absent
|
||||
register: remove_sole_task
|
||||
|
||||
- name: get result of remove sole task in folder
|
||||
test_task_stat:
|
||||
path: '{{test_scheduled_task_path}}'
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
register: remove_sole_task_result
|
||||
|
||||
- name: assert results of remove sole task in folder
|
||||
assert:
|
||||
that:
|
||||
- remove_sole_task|changed
|
||||
- remove_sole_task_result.folder_exists == False
|
||||
- remove_sole_task_result.task_exists == False
|
||||
|
||||
- name: remove sole task in folder (idempotent)
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
path: '{{test_scheduled_task_path}}'
|
||||
state: absent
|
||||
register: remove_sole_task_again
|
||||
|
||||
- name: assert results of remove sole task in folder (idempotent)
|
||||
assert:
|
||||
that:
|
||||
- not remove_sole_task_again|changed
|
436
test/integration/targets/win_scheduled_task/tasks/principals.yml
Normal file
436
test/integration/targets/win_scheduled_task/tasks/principals.yml
Normal file
|
@ -0,0 +1,436 @@
|
|||
---
|
||||
- name: create test user
|
||||
win_user:
|
||||
name: '{{test_scheduled_task_user}}'
|
||||
password: '{{test_scheduled_task_pass}}'
|
||||
state: present
|
||||
groups:
|
||||
- Administrators
|
||||
|
||||
- name: task with password principal (check mode)
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
username: '{{test_scheduled_task_user}}'
|
||||
password: '{{test_scheduled_task_pass}}'
|
||||
logon_type: password
|
||||
update_password: no
|
||||
actions:
|
||||
- path: cmd.exe
|
||||
register: task_with_password_check
|
||||
check_mode: yes
|
||||
|
||||
- name: get result of task with password principal (check mode)
|
||||
test_task_stat:
|
||||
path: \
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
register: task_with_password_result_check
|
||||
|
||||
- name: assert results of task with password principal (check mode)
|
||||
assert:
|
||||
that:
|
||||
- task_with_password_check|changed
|
||||
- task_with_password_result_check.task_exists == False
|
||||
|
||||
- name: task with password principal
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
username: '{{test_scheduled_task_user}}'
|
||||
password: '{{test_scheduled_task_pass}}'
|
||||
logon_type: password
|
||||
update_password: no
|
||||
actions:
|
||||
- path: cmd.exe
|
||||
register: task_with_password
|
||||
|
||||
- name: get result of task with password principal
|
||||
test_task_stat:
|
||||
path: \
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
register: task_with_password_result
|
||||
|
||||
- name: assert results of task with password principal
|
||||
assert:
|
||||
that:
|
||||
- task_with_password|changed
|
||||
- task_with_password_result.task_exists == True
|
||||
- task_with_password_result.task.principal.GroupId == None
|
||||
- task_with_password_result.task.principal.LogonType == "TASK_LOGON_PASSWORD"
|
||||
- task_with_password_result.task.principal.RunLevel == "TASK_RUNLEVEL_LUA"
|
||||
- task_with_password_result.task.principal.UserId.endswith(test_scheduled_task_user)
|
||||
|
||||
- name: task with password principal (idempotent)
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
username: '{{test_scheduled_task_user}}'
|
||||
password: '{{test_scheduled_task_pass}}'
|
||||
logon_type: password
|
||||
update_password: no
|
||||
actions:
|
||||
- path: cmd.exe
|
||||
register: task_with_password_again
|
||||
|
||||
- name: assert results of task with password principal (idempotent)
|
||||
assert:
|
||||
that:
|
||||
- not task_with_password_again|changed
|
||||
|
||||
- name: task with password principal force pass change
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
username: '{{test_scheduled_task_user}}'
|
||||
password: '{{test_scheduled_task_pass}}'
|
||||
logon_type: password
|
||||
update_password: yes
|
||||
actions:
|
||||
- path: cmd.exe
|
||||
register: task_with_password_force_update
|
||||
|
||||
- name: assert results of task with password principal force pass change
|
||||
assert:
|
||||
that:
|
||||
- task_with_password_force_update|changed
|
||||
|
||||
- name: task with s4u principal (check mode)
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
username: '{{test_scheduled_task_user}}'
|
||||
password: '{{test_scheduled_task_pass}}'
|
||||
logon_type: s4u
|
||||
update_password: no
|
||||
actions:
|
||||
- path: cmd.exe
|
||||
register: task_with_s4u_check
|
||||
check_mode: yes
|
||||
|
||||
- name: get result of task with s4u principal (check mode)
|
||||
test_task_stat:
|
||||
path: \
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
register: task_with_s4u_result_check
|
||||
|
||||
- name: assert results of task with s4u principal (check mode)
|
||||
assert:
|
||||
that:
|
||||
- task_with_s4u_check|changed
|
||||
- task_with_s4u_result_check.task_exists == True
|
||||
- task_with_s4u_result_check.task.principal.GroupId == None
|
||||
- task_with_s4u_result_check.task.principal.LogonType == "TASK_LOGON_PASSWORD"
|
||||
- task_with_s4u_result_check.task.principal.RunLevel == "TASK_RUNLEVEL_LUA"
|
||||
- task_with_s4u_result_check.task.principal.UserId.endswith(test_scheduled_task_user)
|
||||
|
||||
- name: task with s4u principal
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
username: '{{test_scheduled_task_user}}'
|
||||
password: '{{test_scheduled_task_pass}}'
|
||||
logon_type: s4u
|
||||
update_password: no
|
||||
actions:
|
||||
- path: cmd.exe
|
||||
register: task_with_s4u
|
||||
|
||||
- name: get result of task with s4u principal
|
||||
test_task_stat:
|
||||
path: \
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
register: task_with_s4u_result
|
||||
|
||||
- name: assert results of task with s4u principal
|
||||
assert:
|
||||
that:
|
||||
- task_with_s4u|changed
|
||||
- task_with_s4u_result.task_exists == True
|
||||
- task_with_s4u_result.task.principal.GroupId == None
|
||||
- task_with_s4u_result.task.principal.LogonType == "TASK_LOGON_S4U"
|
||||
- task_with_s4u_result.task.principal.RunLevel == "TASK_RUNLEVEL_LUA"
|
||||
- task_with_s4u_result.task.principal.UserId.endswith(test_scheduled_task_user)
|
||||
|
||||
- name: task with s4u principal (idempotent)
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
username: '{{test_scheduled_task_user}}'
|
||||
password: '{{test_scheduled_task_pass}}'
|
||||
logon_type: s4u
|
||||
update_password: no
|
||||
actions:
|
||||
- path: cmd.exe
|
||||
register: task_with_s4u_again
|
||||
|
||||
- name: assert results of task with s4u principal (idempotent)
|
||||
assert:
|
||||
that:
|
||||
- not task_with_s4u_again|changed
|
||||
|
||||
- name: task with interactive principal (check mode)
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
username: '{{test_scheduled_task_user}}'
|
||||
logon_type: interactive_token
|
||||
actions:
|
||||
- path: cmd.exe
|
||||
register: task_with_interactive_check
|
||||
check_mode: yes
|
||||
|
||||
- name: get result of task with interactive principal (check mode)
|
||||
test_task_stat:
|
||||
path: \
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
register: task_with_interactive_result_check
|
||||
|
||||
- name: assert results of task with interactive principal (check mode)
|
||||
assert:
|
||||
that:
|
||||
- task_with_interactive_check|changed
|
||||
- task_with_interactive_result_check.task_exists == True
|
||||
- task_with_interactive_result_check.task.principal.GroupId == None
|
||||
- task_with_interactive_result_check.task.principal.LogonType == "TASK_LOGON_S4U"
|
||||
- task_with_interactive_result_check.task.principal.RunLevel == "TASK_RUNLEVEL_LUA"
|
||||
- task_with_interactive_result_check.task.principal.UserId.endswith(test_scheduled_task_user)
|
||||
|
||||
- name: task with interactive principal
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
username: '{{test_scheduled_task_user}}'
|
||||
logon_type: interactive_token
|
||||
actions:
|
||||
- path: cmd.exe
|
||||
register: task_with_interactive
|
||||
|
||||
- name: get result of task with interactive principal
|
||||
test_task_stat:
|
||||
path: \
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
register: task_with_interactive_result
|
||||
|
||||
- name: assert results of task with interactive principal
|
||||
assert:
|
||||
that:
|
||||
- task_with_interactive|changed
|
||||
- task_with_interactive_result.task_exists == True
|
||||
- task_with_interactive_result.task.principal.GroupId == None
|
||||
- task_with_interactive_result.task.principal.LogonType == "TASK_LOGON_INTERACTIVE_TOKEN"
|
||||
- task_with_interactive_result.task.principal.RunLevel == "TASK_RUNLEVEL_LUA"
|
||||
- task_with_interactive_result.task.principal.UserId.endswith(test_scheduled_task_user)
|
||||
|
||||
- name: task with interactive principal (idempotent)
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
username: '{{test_scheduled_task_user}}'
|
||||
logon_type: interactive_token
|
||||
actions:
|
||||
- path: cmd.exe
|
||||
register: task_with_interactive_again
|
||||
|
||||
- name: assert results of task with interactive principal (idempotent)
|
||||
assert:
|
||||
that:
|
||||
- not task_with_interactive_again|changed
|
||||
|
||||
- name: task with group principal (check mode)
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
group: Administrators
|
||||
logon_type: group
|
||||
actions:
|
||||
- path: cmd.exe
|
||||
register: task_with_group_check
|
||||
check_mode: yes
|
||||
|
||||
- name: get result of task with group principal (check mode)
|
||||
test_task_stat:
|
||||
path: \
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
register: task_with_group_result_check
|
||||
|
||||
- name: assert results of task with group principal (check mode)
|
||||
assert:
|
||||
that:
|
||||
- task_with_group_check|changed
|
||||
- task_with_group_result_check.task_exists == True
|
||||
- task_with_group_result_check.task.principal.GroupId == None
|
||||
- task_with_group_result_check.task.principal.LogonType == "TASK_LOGON_INTERACTIVE_TOKEN"
|
||||
- task_with_group_result_check.task.principal.RunLevel == "TASK_RUNLEVEL_LUA"
|
||||
- task_with_group_result_check.task.principal.UserId.endswith(test_scheduled_task_user)
|
||||
|
||||
- name: task with group principal
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
group: Administrators
|
||||
logon_type: group
|
||||
actions:
|
||||
- path: cmd.exe
|
||||
register: task_with_group
|
||||
|
||||
- name: get result of task with group principal
|
||||
test_task_stat:
|
||||
path: \
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
register: task_with_group_result
|
||||
|
||||
- name: assert results of task with group principal
|
||||
assert:
|
||||
that:
|
||||
- task_with_group|changed
|
||||
- task_with_group_result.task_exists == True
|
||||
- task_with_group_result.task.principal.GroupId == "BUILTIN\\Administrators"
|
||||
- task_with_group_result.task.principal.LogonType == "TASK_LOGON_GROUP"
|
||||
- task_with_group_result.task.principal.RunLevel == "TASK_RUNLEVEL_LUA"
|
||||
- task_with_group_result.task.principal.UserId == None
|
||||
|
||||
- name: task with group principal (idempotent)
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
group: Administrators
|
||||
logon_type: group
|
||||
actions:
|
||||
- path: cmd.exe
|
||||
register: task_with_group_again
|
||||
|
||||
- name: assert results of task with group principal (idempotent)
|
||||
assert:
|
||||
that:
|
||||
- not task_with_group_again|changed
|
||||
|
||||
- name: task with service account principal (check mode)
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
username: System
|
||||
logon_type: service_account
|
||||
action:
|
||||
- path: cmd.exe
|
||||
register: task_with_service_check
|
||||
check_mode: yes
|
||||
|
||||
- name: get result of task with service account principal (check mode)
|
||||
test_task_stat:
|
||||
path: \
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
register: task_with_service_result_check
|
||||
|
||||
- name: assert results of task with service account principal (check mode)
|
||||
assert:
|
||||
that:
|
||||
- task_with_service_check|changed
|
||||
- task_with_service_result_check.task_exists == True
|
||||
- task_with_service_result_check.task.principal.GroupId == "BUILTIN\\Administrators"
|
||||
- task_with_service_result_check.task.principal.LogonType == "TASK_LOGON_GROUP"
|
||||
- task_with_service_result_check.task.principal.RunLevel == "TASK_RUNLEVEL_LUA"
|
||||
- task_with_service_result_check.task.principal.UserId == None
|
||||
|
||||
- name: task with service account principal
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
username: System
|
||||
logon_type: service_account
|
||||
action:
|
||||
- path: cmd.exe
|
||||
register: task_with_service
|
||||
|
||||
- name: get result of task with service account principal
|
||||
test_task_stat:
|
||||
path: \
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
register: task_with_service_result
|
||||
|
||||
- name: assert results of task with service account principal
|
||||
assert:
|
||||
that:
|
||||
- task_with_service|changed
|
||||
- task_with_service_result.task_exists == True
|
||||
- task_with_service_result.task.principal.GroupId == None
|
||||
- task_with_service_result.task.principal.LogonType == "TASK_LOGON_SERVICE_ACCOUNT"
|
||||
- task_with_service_result.task.principal.RunLevel == "TASK_RUNLEVEL_LUA"
|
||||
- task_with_service_result.task.principal.UserId == "NT AUTHORITY\\SYSTEM"
|
||||
|
||||
- name: task with service account principal (idempotent)
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
username: System
|
||||
logon_type: service_account
|
||||
action:
|
||||
- path: cmd.exe
|
||||
register: task_with_service_again
|
||||
|
||||
- name: assert results of task with service account principal (idempotent)
|
||||
assert:
|
||||
that:
|
||||
- not task_with_service_again|changed
|
||||
|
||||
- name: task with highest privilege (check mode)
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
run_level: highest
|
||||
username: System
|
||||
logon_type: service_account
|
||||
action:
|
||||
- path: cmd.exe
|
||||
register: task_with_highest_privilege_check
|
||||
check_mode: yes
|
||||
|
||||
- name: get result of task with highest privilege (check mode)
|
||||
test_task_stat:
|
||||
path: \
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
register: task_with_highest_privilege_result_check
|
||||
|
||||
- name: assert results of task with highest privilege (check mode)
|
||||
assert:
|
||||
that:
|
||||
- task_with_highest_privilege_check|changed
|
||||
- task_with_highest_privilege_result_check.task.principal.RunLevel == "TASK_RUNLEVEL_LUA"
|
||||
|
||||
- name: task with highest privilege
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
run_level: highest
|
||||
username: System
|
||||
logon_type: service_account
|
||||
action:
|
||||
- path: cmd.exe
|
||||
register: task_with_highest_privilege
|
||||
|
||||
- name: get result of task with highest privilege
|
||||
test_task_stat:
|
||||
path: \
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
register: task_with_highest_privilege_result
|
||||
|
||||
- name: assert results of task with highest privilege
|
||||
assert:
|
||||
that:
|
||||
- task_with_highest_privilege|changed
|
||||
- task_with_highest_privilege_result.task.principal.RunLevel == "TASK_RUNLEVEL_HIGHEST"
|
||||
|
||||
- name: task with highest privilege (idempotent)
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
run_level: highest
|
||||
username: System
|
||||
logon_type: service_account
|
||||
action:
|
||||
- path: cmd.exe
|
||||
register: task_with_highest_privilege_again
|
||||
|
||||
- name: assert results of task with highest privilege (idempotent)
|
||||
assert:
|
||||
that:
|
||||
- not task_with_highest_privilege_again|changed
|
|
@ -1,3 +1,6 @@
|
|||
# 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
|
||||
|
@ -18,7 +21,6 @@
|
|||
assert:
|
||||
that:
|
||||
- add_scheduled_task.changed == true
|
||||
- add_scheduled_task.exists == false
|
||||
|
||||
|
||||
- name: Add scheduled task (again)
|
||||
|
@ -29,14 +31,12 @@
|
|||
assert:
|
||||
that:
|
||||
- add_scheduled_task_again.changed == false
|
||||
- add_scheduled_task_again.exists == true
|
||||
when: not in_check_mode
|
||||
|
||||
- name: Test add_scheduled_task_again (check-mode)
|
||||
assert:
|
||||
that:
|
||||
- add_scheduled_task_again.changed == true
|
||||
- add_scheduled_task_again.exists == false
|
||||
when: in_check_mode
|
||||
|
||||
|
||||
|
@ -56,7 +56,6 @@
|
|||
assert:
|
||||
that:
|
||||
- disable_scheduled_task.changed == true
|
||||
- disable_scheduled_task.exists == true
|
||||
|
||||
|
||||
- name: Disable scheduled task (again)
|
||||
|
@ -69,7 +68,6 @@
|
|||
assert:
|
||||
that:
|
||||
- disable_scheduled_task_again.changed == false
|
||||
- disable_scheduled_task_again.exists == true
|
||||
|
||||
|
||||
- name: Enable scheduled task
|
||||
|
@ -81,7 +79,6 @@
|
|||
- assert:
|
||||
that:
|
||||
- enable_scheduled_task.changed == true
|
||||
- enable_scheduled_task.exists == true
|
||||
|
||||
- name: Enable scheduled task (again)
|
||||
win_scheduled_task:
|
||||
|
@ -92,7 +89,6 @@
|
|||
- assert:
|
||||
that:
|
||||
- enable_scheduled_task_again.changed == false
|
||||
- enable_scheduled_task_again.exists == true
|
||||
|
||||
|
||||
- name: Remove scheduled task
|
||||
|
@ -103,14 +99,12 @@
|
|||
assert:
|
||||
that:
|
||||
- remove_scheduled_task.changed == true
|
||||
- remove_scheduled_task.exists == true
|
||||
when: not in_check_mode
|
||||
|
||||
- name: Test remove_scheduled_task (check-mode)
|
||||
assert:
|
||||
that:
|
||||
- remove_scheduled_task.changed == false
|
||||
- remove_scheduled_task.exists == false
|
||||
when: in_check_mode
|
||||
|
||||
|
||||
|
@ -122,7 +116,6 @@
|
|||
assert:
|
||||
that:
|
||||
- remove_scheduled_task_again.changed == false
|
||||
- remove_scheduled_task_again.exists == false
|
||||
|
||||
|
||||
# Test scheduled task path creation and removal
|
||||
|
@ -157,7 +150,7 @@
|
|||
- name: Test add_scheduled_task_new_path_1
|
||||
assert:
|
||||
that:
|
||||
- add_scheduled_task_new_path_1.msg == 'Added new task Ansible Test New Path 1 and task path \\non_existent_path\\ created'
|
||||
- add_scheduled_task_new_path_1|changed
|
||||
|
||||
|
||||
- name: Add scheduled task new path 2
|
||||
|
@ -169,13 +162,13 @@
|
|||
- name: Test add_scheduled_task_new_path_2 (normal mode)
|
||||
assert:
|
||||
that:
|
||||
- add_scheduled_task_new_path_2.msg == 'Added new task Ansible Test New Path 2'
|
||||
- add_scheduled_task_new_path_2|changed
|
||||
when: not in_check_mode
|
||||
|
||||
- name: Test add_scheduled_task_new_path_2 (check-mode)
|
||||
assert:
|
||||
that:
|
||||
- add_scheduled_task_new_path_2.msg == 'Added new task Ansible Test New Path 2 and task path \\non_existent_path\\ created'
|
||||
- add_scheduled_task_new_path_2|changed
|
||||
when: in_check_mode
|
||||
|
||||
|
||||
|
@ -186,13 +179,13 @@
|
|||
- name: Test remove_scheduled_task_new_path_2 (normal mode)
|
||||
assert:
|
||||
that:
|
||||
- remove_scheduled_task_new_path_2.msg == 'Deleted task Ansible Test New Path 2'
|
||||
- remove_scheduled_task_new_path_2|changed
|
||||
when: not in_check_mode
|
||||
|
||||
- name: Test remove_scheduled_task_new_path_2 (check-mode)
|
||||
assert:
|
||||
that:
|
||||
- remove_scheduled_task_new_path_2.msg == 'Task does not exist'
|
||||
- not remove_scheduled_task_new_path_2|changed
|
||||
when: in_check_mode
|
||||
|
||||
|
||||
|
@ -203,13 +196,13 @@
|
|||
- name: Test remove_scheduled_task_new_path_1 (normal mode)
|
||||
assert:
|
||||
that:
|
||||
- remove_scheduled_task_new_path_1.msg == 'Deleted task Ansible Test New Path 1 and task path \\non_existent_path\\ removed'
|
||||
- remove_scheduled_task_new_path_1|changed
|
||||
when: not in_check_mode
|
||||
|
||||
- name: Test remove_scheduled_task_new_path_1 (check-mode)
|
||||
assert:
|
||||
that:
|
||||
- remove_scheduled_task_new_path_1.msg == 'Task does not exist'
|
||||
- not remove_scheduled_task_new_path_1|changed
|
||||
when: in_check_mode
|
||||
|
||||
|
||||
|
@ -238,7 +231,6 @@
|
|||
assert:
|
||||
that:
|
||||
- add_scheduled_task_run_options_1.changed == true
|
||||
- add_scheduled_task_run_options_1.exists == false
|
||||
|
||||
|
||||
- name: Execute run options tests for normal mode only (expects scheduled task)
|
||||
|
@ -255,7 +247,6 @@
|
|||
assert:
|
||||
that:
|
||||
- change_scheduled_task_run_options_user.changed == true
|
||||
- change_scheduled_task_run_options_user.exists == true
|
||||
|
||||
|
||||
- name: Change scheduled task run options user (again)
|
||||
|
@ -268,7 +259,6 @@
|
|||
assert:
|
||||
that:
|
||||
- change_scheduled_task_run_options_user_again.changed == false
|
||||
- change_scheduled_task_run_options_user_again.exists == true
|
||||
|
||||
|
||||
- name: Change scheduled task run options run level
|
||||
|
@ -282,7 +272,6 @@
|
|||
assert:
|
||||
that:
|
||||
- change_scheduled_task_run_options_runlevel.changed == true
|
||||
- change_scheduled_task_run_options_runlevel.exists == true
|
||||
|
||||
|
||||
- name: Change scheduled task run options run level (again)
|
||||
|
@ -296,7 +285,6 @@
|
|||
assert:
|
||||
that:
|
||||
- change_scheduled_task_run_options_runlevel_again.changed == false
|
||||
- change_scheduled_task_run_options_runlevel_again.exists == true
|
||||
|
||||
|
||||
# Should ignore change as account being tested is a built-in service account
|
||||
|
@ -312,7 +300,6 @@
|
|||
assert:
|
||||
that:
|
||||
- change_scheduled_task_run_options_store_password.changed == false
|
||||
- change_scheduled_task_run_options_store_password.exists == true
|
||||
|
||||
|
||||
- name: Remove scheduled task run options 1
|
||||
|
@ -323,12 +310,10 @@
|
|||
assert:
|
||||
that:
|
||||
- remove_scheduled_task_run_options_1.changed == true
|
||||
- remove_scheduled_task_run_options_1.exists == 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
|
||||
- remove_scheduled_task_run_options_1.exists == false
|
||||
when: in_check_mode
|
||||
|
|
635
test/integration/targets/win_scheduled_task/tasks/triggers.yml
Normal file
635
test/integration/targets/win_scheduled_task/tasks/triggers.yml
Normal file
|
@ -0,0 +1,635 @@
|
|||
---
|
||||
- name: create boot trigger (check mode)
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
actions:
|
||||
- path: cmd.exe
|
||||
triggers:
|
||||
- type: boot
|
||||
register: trigger_boot_check
|
||||
check_mode: yes
|
||||
|
||||
- name: get result of create boot trigger (check mode)
|
||||
test_task_stat:
|
||||
path: \
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
register: trigger_boot_result_check
|
||||
|
||||
- name: assert results of create boot trigger (check mode)
|
||||
assert:
|
||||
that:
|
||||
- trigger_boot_check|changed
|
||||
- trigger_boot_result_check.task_exists == False
|
||||
|
||||
- name: create boot trigger
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
actions:
|
||||
- path: cmd.exe
|
||||
triggers:
|
||||
- type: boot
|
||||
register: trigger_boot
|
||||
|
||||
- name: get result of create boot trigger
|
||||
test_task_stat:
|
||||
path: \
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
register: trigger_boot_result
|
||||
|
||||
- name: assert results of create boot trigger
|
||||
assert:
|
||||
that:
|
||||
- trigger_boot|changed
|
||||
- trigger_boot_result.task_exists == True
|
||||
- trigger_boot_result.task.triggers|count == 1
|
||||
- trigger_boot_result.task.triggers[0].Type == "TASK_TRIGGER_BOOT"
|
||||
- trigger_boot_result.task.triggers[0].Enabled == True
|
||||
- trigger_boot_result.task.triggers[0].StartBoundary == None
|
||||
- trigger_boot_result.task.triggers[0].EndBoundary == None
|
||||
|
||||
- name: create boot trigger (idempotent)
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
actions:
|
||||
- path: cmd.exe
|
||||
triggers:
|
||||
- type: boot
|
||||
register: trigger_boot_again
|
||||
|
||||
- name: assert results of create boot trigger (idempotent)
|
||||
assert:
|
||||
that:
|
||||
- not trigger_boot_again|changed
|
||||
|
||||
- name: create daily trigger (check mode)
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
actions:
|
||||
- path: cmd.exe
|
||||
triggers:
|
||||
- type: daily
|
||||
start_boundary: '2000-01-01T00:00:01'
|
||||
register: trigger_daily_check
|
||||
check_mode: yes
|
||||
|
||||
- name: get result of create daily trigger (check mode)
|
||||
test_task_stat:
|
||||
path: \
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
register: trigger_daily_result_check
|
||||
|
||||
- name: assert results of create daily trigger (check mode)
|
||||
assert:
|
||||
that:
|
||||
- trigger_daily_check|changed
|
||||
- trigger_daily_result_check.task_exists == True
|
||||
- trigger_daily_result_check.task.triggers|count == 1
|
||||
- trigger_daily_result_check.task.triggers[0].Type == "TASK_TRIGGER_BOOT"
|
||||
- trigger_daily_result_check.task.triggers[0].Enabled == True
|
||||
- trigger_daily_result_check.task.triggers[0].StartBoundary == None
|
||||
- trigger_daily_result_check.task.triggers[0].EndBoundary == None
|
||||
|
||||
- name: create daily trigger
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
actions:
|
||||
- path: cmd.exe
|
||||
triggers:
|
||||
- type: daily
|
||||
start_boundary: '2000-01-01T00:00:01'
|
||||
register: trigger_daily
|
||||
|
||||
- name: get result of create daily trigger
|
||||
test_task_stat:
|
||||
path: \
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
register: trigger_daily_result
|
||||
|
||||
- name: assert results of create daily trigger
|
||||
assert:
|
||||
that:
|
||||
- trigger_daily|changed
|
||||
- trigger_daily_result.task_exists == True
|
||||
- trigger_daily_result.task.triggers|count == 1
|
||||
- trigger_daily_result.task.triggers[0].Type == "TASK_TRIGGER_DAILY"
|
||||
- trigger_daily_result.task.triggers[0].Enabled == True
|
||||
- trigger_daily_result.task.triggers[0].StartBoundary == "2000-01-01T00:00:01"
|
||||
- trigger_daily_result.task.triggers[0].EndBoundary == None
|
||||
|
||||
- name: create daily trigger (idempotent)
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
actions:
|
||||
- path: cmd.exe
|
||||
triggers:
|
||||
- type: daily
|
||||
start_boundary: '2000-01-01T00:00:01'
|
||||
register: trigger_daily_again
|
||||
|
||||
- name: assert results of create daily trigger (idempotent)
|
||||
assert:
|
||||
that:
|
||||
- not trigger_daily_again|changed
|
||||
|
||||
- name: create logon trigger (check mode)
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
actions:
|
||||
- path: cmd.exe
|
||||
triggers:
|
||||
- type: logon
|
||||
register: trigger_logon_check
|
||||
check_mode: yes
|
||||
|
||||
- name: get result of create logon trigger (check mode)
|
||||
test_task_stat:
|
||||
path: \
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
register: trigger_logon_result_check
|
||||
|
||||
- name: assert results of create logon trigger
|
||||
assert:
|
||||
that:
|
||||
- trigger_logon_check|changed
|
||||
- trigger_logon_result_check.task_exists == True
|
||||
- trigger_logon_result_check.task.triggers|count == 1
|
||||
- trigger_logon_result_check.task.triggers[0].Type == "TASK_TRIGGER_DAILY"
|
||||
- trigger_logon_result_check.task.triggers[0].Enabled == True
|
||||
- trigger_logon_result_check.task.triggers[0].StartBoundary == "2000-01-01T00:00:01"
|
||||
- trigger_logon_result_check.task.triggers[0].EndBoundary == None
|
||||
|
||||
- name: create logon trigger
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
actions:
|
||||
- path: cmd.exe
|
||||
triggers:
|
||||
- type: logon
|
||||
register: trigger_logon
|
||||
|
||||
- name: get result of create logon trigger
|
||||
test_task_stat:
|
||||
path: \
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
register: trigger_logon_result
|
||||
|
||||
- name: assert results of create logon trigger
|
||||
assert:
|
||||
that:
|
||||
- trigger_logon|changed
|
||||
- trigger_logon_result.task_exists == True
|
||||
- trigger_logon_result.task.triggers|count == 1
|
||||
- trigger_logon_result.task.triggers[0].Type == "TASK_TRIGGER_LOGON"
|
||||
- trigger_logon_result.task.triggers[0].Enabled == True
|
||||
- trigger_logon_result.task.triggers[0].StartBoundary == None
|
||||
- trigger_logon_result.task.triggers[0].EndBoundary == None
|
||||
|
||||
- name: create logon trigger (idempotent)
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
actions:
|
||||
- path: cmd.exe
|
||||
triggers:
|
||||
- type: logon
|
||||
register: trigger_logon_again
|
||||
|
||||
- name: assert results of create logon trigger (idempotent)
|
||||
assert:
|
||||
that:
|
||||
- not trigger_logon_again|changed
|
||||
|
||||
- name: create monthly dow trigger (check mode)
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
actions:
|
||||
- path: cmd.exe
|
||||
triggers:
|
||||
- type: monthlydow
|
||||
start_boundary: '2000-01-01T00:00:01'
|
||||
weeks_of_month: 1,2
|
||||
days_of_week: [ "monday", "wednesday" ]
|
||||
register: trigger_monthlydow_check
|
||||
check_mode: yes
|
||||
|
||||
- name: get result of create monthly dow trigger (check mode)
|
||||
test_task_stat:
|
||||
path: \
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
register: trigger_monthlydow_result_check
|
||||
|
||||
- name: assert results of create monthly dow trigger (check mode)
|
||||
assert:
|
||||
that:
|
||||
- trigger_monthlydow_check|changed
|
||||
- trigger_monthlydow_result_check.task_exists == True
|
||||
- trigger_monthlydow_result_check.task.triggers|count == 1
|
||||
- trigger_monthlydow_result_check.task.triggers[0].Type == "TASK_TRIGGER_LOGON"
|
||||
- trigger_monthlydow_result_check.task.triggers[0].Enabled == True
|
||||
- trigger_monthlydow_result_check.task.triggers[0].StartBoundary == None
|
||||
- trigger_monthlydow_result_check.task.triggers[0].EndBoundary == None
|
||||
|
||||
- name: create monthly dow trigger
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
actions:
|
||||
- path: cmd.exe
|
||||
triggers:
|
||||
- type: monthlydow
|
||||
start_boundary: '2000-01-01T00:00:01'
|
||||
weeks_of_month: 1,2
|
||||
days_of_week: [ "monday", "wednesday" ]
|
||||
register: trigger_monthlydow
|
||||
|
||||
- name: get result of create monthly dow trigger
|
||||
test_task_stat:
|
||||
path: \
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
register: trigger_monthlydow_result
|
||||
|
||||
- name: assert results of create monthly dow trigger
|
||||
assert:
|
||||
that:
|
||||
- trigger_monthlydow|changed
|
||||
- trigger_monthlydow_result.task_exists == True
|
||||
- trigger_monthlydow_result.task.triggers|count == 1
|
||||
- trigger_monthlydow_result.task.triggers[0].Type == "TASK_TRIGGER_MONTHLYDOW"
|
||||
- trigger_monthlydow_result.task.triggers[0].Enabled == True
|
||||
- trigger_monthlydow_result.task.triggers[0].StartBoundary == "2000-01-01T00:00:01"
|
||||
- trigger_monthlydow_result.task.triggers[0].EndBoundary == None
|
||||
- trigger_monthlydow_result.task.triggers[0].WeeksOfMonth == "1,2"
|
||||
- trigger_monthlydow_result.task.triggers[0].DaysOfWeek == "monday,wednesday"
|
||||
|
||||
- name: create monthly dow trigger (idempotent)
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
actions:
|
||||
- path: cmd.exe
|
||||
triggers:
|
||||
- type: monthlydow
|
||||
start_boundary: '2000-01-01T00:00:01'
|
||||
weeks_of_month: 1,2
|
||||
days_of_week: [ "monday", "wednesday" ]
|
||||
register: trigger_monthlydow_again
|
||||
|
||||
- name: assert results of create monthly dow trigger (idempotent)
|
||||
assert:
|
||||
that:
|
||||
- not trigger_monthlydow_again|changed
|
||||
|
||||
- name: create task with multiple triggers (check mode)
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
actions:
|
||||
- path: cmd.exe
|
||||
triggers:
|
||||
- type: monthly
|
||||
days_of_month: 1,5,10,15,20,25,30
|
||||
run_on_last_day_of_month: true
|
||||
start_boundary: '2000-01-01T00:00:01'
|
||||
months_of_year:
|
||||
- march
|
||||
- may
|
||||
- july
|
||||
- type: time
|
||||
start_boundary: '2000-01-01T00:00:01'
|
||||
random_delay: PT10M5S
|
||||
register: create_multiple_triggers_check
|
||||
check_mode: yes
|
||||
|
||||
- name: get result of create task with multiple triggers (check mode)
|
||||
test_task_stat:
|
||||
path: \
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
register: create_multiple_triggers_result_check
|
||||
|
||||
- name: assert results of create task with multiple triggers (check mode)
|
||||
assert:
|
||||
that:
|
||||
- create_multiple_triggers_check|changed
|
||||
- create_multiple_triggers_result_check.task_exists == True
|
||||
- create_multiple_triggers_result_check.task.triggers|count == 1
|
||||
- create_multiple_triggers_result_check.task.triggers[0].Type == "TASK_TRIGGER_MONTHLYDOW"
|
||||
- create_multiple_triggers_result_check.task.triggers[0].Enabled == True
|
||||
- create_multiple_triggers_result_check.task.triggers[0].StartBoundary == "2000-01-01T00:00:01"
|
||||
- create_multiple_triggers_result_check.task.triggers[0].EndBoundary == None
|
||||
- create_multiple_triggers_result_check.task.triggers[0].WeeksOfMonth == "1,2"
|
||||
- create_multiple_triggers_result_check.task.triggers[0].DaysOfWeek == "monday,wednesday"
|
||||
|
||||
- name: create task with multiple triggers
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
actions:
|
||||
- path: cmd.exe
|
||||
triggers:
|
||||
- type: monthly
|
||||
days_of_month: 1,5,10,15,20,25,30
|
||||
run_on_last_day_of_month: true
|
||||
start_boundary: '2000-01-01T00:00:01'
|
||||
months_of_year:
|
||||
- march
|
||||
- may
|
||||
- july
|
||||
- type: time
|
||||
start_boundary: '2000-01-01T00:00:01'
|
||||
random_delay: PT10M5S
|
||||
register: create_multiple_triggers
|
||||
|
||||
- name: get result of create task with multiple triggers
|
||||
test_task_stat:
|
||||
path: \
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
register: create_multiple_triggers_result
|
||||
|
||||
- name: assert results of create task with multiple triggers
|
||||
assert:
|
||||
that:
|
||||
- create_multiple_triggers|changed
|
||||
- create_multiple_triggers_result.task_exists == True
|
||||
- create_multiple_triggers_result.task.triggers|count == 2
|
||||
- create_multiple_triggers_result.task.triggers[0].Type == "TASK_TRIGGER_MONTHLY"
|
||||
- create_multiple_triggers_result.task.triggers[0].Enabled == True
|
||||
- create_multiple_triggers_result.task.triggers[0].StartBoundary == "2000-01-01T00:00:01"
|
||||
- create_multiple_triggers_result.task.triggers[0].EndBoundary == None
|
||||
- create_multiple_triggers_result.task.triggers[0].DaysOfMonth == "1,5,10,15,20,25,30"
|
||||
- create_multiple_triggers_result.task.triggers[0].MonthsOfYear == "march,may,july"
|
||||
- create_multiple_triggers_result.task.triggers[0].RunOnLastDayOfMonth == True
|
||||
- create_multiple_triggers_result.task.triggers[1].Type == "TASK_TRIGGER_TIME"
|
||||
- create_multiple_triggers_result.task.triggers[1].Enabled == True
|
||||
- create_multiple_triggers_result.task.triggers[1].StartBoundary == "2000-01-01T00:00:01"
|
||||
- create_multiple_triggers_result.task.triggers[1].EndBoundary == None
|
||||
- create_multiple_triggers_result.task.triggers[1].RandomDelay == "PT10M5S"
|
||||
|
||||
- name: create task with multiple triggers (idempotent)
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
actions:
|
||||
- path: cmd.exe
|
||||
triggers:
|
||||
- type: monthly
|
||||
days_of_month: 1,5,10,15,20,25,30
|
||||
run_on_last_day_of_month: true
|
||||
start_boundary: '2000-01-01T00:00:01'
|
||||
months_of_year:
|
||||
- march
|
||||
- may
|
||||
- july
|
||||
- type: time
|
||||
start_boundary: '2000-01-01T00:00:01'
|
||||
random_delay: PT10M5S
|
||||
register: create_multiple_triggers_again
|
||||
|
||||
- name: assert results of create task with multiple triggers (idempotent)
|
||||
assert:
|
||||
that:
|
||||
- not create_multiple_triggers_again|changed
|
||||
|
||||
- name: change task with multiple triggers (check mode)
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
actions:
|
||||
- path: cmd.exe
|
||||
triggers:
|
||||
- type: weekly
|
||||
days_of_week: tuesday,friday
|
||||
start_boundary: '2000-01-01T00:00:01'
|
||||
- type: registration
|
||||
enabled: no
|
||||
register: change_multiple_triggers_check
|
||||
check_mode: yes
|
||||
|
||||
- name: get result of change task with multiple triggers (check mode)
|
||||
test_task_stat:
|
||||
path: \
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
register: change_multiple_triggers_result_check
|
||||
|
||||
- name: assert results of change task with multiple triggers (check mode)
|
||||
assert:
|
||||
that:
|
||||
- change_multiple_triggers_check|changed
|
||||
- change_multiple_triggers_result_check.task_exists == True
|
||||
- change_multiple_triggers_result_check.task.triggers|count == 2
|
||||
- change_multiple_triggers_result_check.task.triggers[0].Type == "TASK_TRIGGER_MONTHLY"
|
||||
- change_multiple_triggers_result_check.task.triggers[0].Enabled == True
|
||||
- change_multiple_triggers_result_check.task.triggers[0].StartBoundary == "2000-01-01T00:00:01"
|
||||
- change_multiple_triggers_result_check.task.triggers[0].EndBoundary == None
|
||||
- change_multiple_triggers_result_check.task.triggers[0].DaysOfMonth == "1,5,10,15,20,25,30"
|
||||
- change_multiple_triggers_result_check.task.triggers[0].MonthsOfYear == "march,may,july"
|
||||
- change_multiple_triggers_result_check.task.triggers[0].RunOnLastDayOfMonth == True
|
||||
- change_multiple_triggers_result_check.task.triggers[1].Type == "TASK_TRIGGER_TIME"
|
||||
- change_multiple_triggers_result_check.task.triggers[1].Enabled == True
|
||||
- change_multiple_triggers_result_check.task.triggers[1].StartBoundary == "2000-01-01T00:00:01"
|
||||
- change_multiple_triggers_result_check.task.triggers[1].EndBoundary == None
|
||||
- change_multiple_triggers_result_check.task.triggers[1].RandomDelay == "PT10M5S"
|
||||
|
||||
- name: change task with multiple triggers
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
actions:
|
||||
- path: cmd.exe
|
||||
triggers:
|
||||
- type: weekly
|
||||
days_of_week: tuesday,friday
|
||||
start_boundary: '2000-01-01T00:00:01'
|
||||
- type: registration
|
||||
enabled: no
|
||||
register: change_multiple_triggers
|
||||
|
||||
- name: get result of change task with multiple triggers
|
||||
test_task_stat:
|
||||
path: \
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
register: change_multiple_triggers_result
|
||||
|
||||
- name: assert results of change task with multiple triggers
|
||||
assert:
|
||||
that:
|
||||
- change_multiple_triggers|changed
|
||||
- change_multiple_triggers_result.task_exists == True
|
||||
- change_multiple_triggers_result.task.triggers|count == 2
|
||||
- change_multiple_triggers_result.task.triggers[0].Type == "TASK_TRIGGER_WEEKLY"
|
||||
- change_multiple_triggers_result.task.triggers[0].Enabled == True
|
||||
- change_multiple_triggers_result.task.triggers[0].StartBoundary == "2000-01-01T00:00:01"
|
||||
- change_multiple_triggers_result.task.triggers[0].EndBoundary == None
|
||||
- change_multiple_triggers_result.task.triggers[0].DaysOfWeek == "tuesday,friday"
|
||||
- change_multiple_triggers_result.task.triggers[1].Type == "TASK_TRIGGER_REGISTRATION"
|
||||
- change_multiple_triggers_result.task.triggers[1].Enabled == False
|
||||
- change_multiple_triggers_result.task.triggers[1].StartBoundary == None
|
||||
- change_multiple_triggers_result.task.triggers[1].EndBoundary == None
|
||||
|
||||
- name: change task with multiple triggers (idempotent)
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
actions:
|
||||
- path: cmd.exe
|
||||
triggers:
|
||||
- type: weekly
|
||||
days_of_week: tuesday,friday
|
||||
start_boundary: '2000-01-01T00:00:01'
|
||||
- type: registration
|
||||
enabled: no
|
||||
register: change_multiple_triggers_again
|
||||
|
||||
- name: assert results of change task with multiple triggers (idempotent)
|
||||
assert:
|
||||
that:
|
||||
- not change_multiple_triggers_again|changed
|
||||
|
||||
- name: remove trigger from multiple triggers (check mode)
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
actions:
|
||||
- path: cmd.exe
|
||||
triggers:
|
||||
- type: registration
|
||||
enabled: no
|
||||
register: remove_single_trigger_check
|
||||
check_mode: yes
|
||||
|
||||
- name: get result of remove trigger from multiple triggers (check mode)
|
||||
test_task_stat:
|
||||
path: \
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
register: remove_single_trigger_result_check
|
||||
|
||||
- name: assert results of remove trigger from multiple triggers (check mode)
|
||||
assert:
|
||||
that:
|
||||
- remove_single_trigger_check|changed
|
||||
- remove_single_trigger_result_check.task_exists == True
|
||||
- remove_single_trigger_result_check.task.triggers|count == 2
|
||||
- remove_single_trigger_result_check.task.triggers[0].Type == "TASK_TRIGGER_WEEKLY"
|
||||
- remove_single_trigger_result_check.task.triggers[0].Enabled == True
|
||||
- remove_single_trigger_result_check.task.triggers[0].StartBoundary == "2000-01-01T00:00:01"
|
||||
- remove_single_trigger_result_check.task.triggers[0].EndBoundary == None
|
||||
- remove_single_trigger_result_check.task.triggers[0].DaysOfWeek == "tuesday,friday"
|
||||
- remove_single_trigger_result_check.task.triggers[1].Type == "TASK_TRIGGER_REGISTRATION"
|
||||
- remove_single_trigger_result_check.task.triggers[1].Enabled == False
|
||||
- remove_single_trigger_result_check.task.triggers[1].StartBoundary == None
|
||||
- remove_single_trigger_result_check.task.triggers[1].EndBoundary == None
|
||||
|
||||
- name: remove trigger from multiple triggers
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
actions:
|
||||
- path: cmd.exe
|
||||
triggers:
|
||||
- type: registration
|
||||
enabled: no
|
||||
register: remove_single_trigger
|
||||
|
||||
- name: get result of remove trigger from multiple triggers
|
||||
test_task_stat:
|
||||
path: \
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
register: remove_single_trigger_result
|
||||
|
||||
- name: assert results of remove trigger from multiple triggers
|
||||
assert:
|
||||
that:
|
||||
- remove_single_trigger|changed
|
||||
- remove_single_trigger_result.task_exists == True
|
||||
- remove_single_trigger_result.task.triggers|count == 1
|
||||
- remove_single_trigger_result.task.triggers[0].Type == "TASK_TRIGGER_REGISTRATION"
|
||||
- remove_single_trigger_result.task.triggers[0].Enabled == False
|
||||
- remove_single_trigger_result.task.triggers[0].StartBoundary == None
|
||||
- remove_single_trigger_result.task.triggers[0].EndBoundary == None
|
||||
|
||||
- name: remove trigger from multiple triggers (idempotent)
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
actions:
|
||||
- path: cmd.exe
|
||||
triggers:
|
||||
- type: registration
|
||||
enabled: no
|
||||
register: remove_single_trigger_again
|
||||
|
||||
- name: assert results of remove trigger from multiple triggers (idempotent)
|
||||
assert:
|
||||
that:
|
||||
- not remove_single_trigger_again|changed
|
||||
|
||||
- name: remove all triggers (check mode)
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
actions:
|
||||
- path: cmd.exe
|
||||
triggers: []
|
||||
register: remove_triggers_check
|
||||
check_mode: yes
|
||||
|
||||
- name: get result of remove all triggers (check mode)
|
||||
test_task_stat:
|
||||
path: \
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
register: remove_triggers_result_check
|
||||
|
||||
- name: assert results of remove all triggers (check mode)
|
||||
assert:
|
||||
that:
|
||||
- remove_triggers_check|changed
|
||||
- remove_triggers_result_check.task_exists == True
|
||||
- remove_triggers_result_check.task.triggers|count == 1
|
||||
- remove_triggers_result_check.task.triggers[0].Type == "TASK_TRIGGER_REGISTRATION"
|
||||
- remove_triggers_result_check.task.triggers[0].Enabled == False
|
||||
- remove_triggers_result_check.task.triggers[0].StartBoundary == None
|
||||
- remove_triggers_result_check.task.triggers[0].EndBoundary == None
|
||||
|
||||
- name: remove all triggers
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
actions:
|
||||
- path: cmd.exe
|
||||
triggers: []
|
||||
register: remove_triggers
|
||||
|
||||
- name: get result of remove all triggers
|
||||
test_task_stat:
|
||||
path: \
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
register: remove_triggers_result
|
||||
|
||||
- name: assert results of remove all triggers
|
||||
assert:
|
||||
that:
|
||||
- remove_triggers|changed
|
||||
- remove_triggers_result.task_exists == True
|
||||
- remove_triggers_result.task.triggers|count == 0
|
||||
|
||||
- name: remove all triggers (idempotent)
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_name}}'
|
||||
state: present
|
||||
actions:
|
||||
- path: cmd.exe
|
||||
triggers: []
|
||||
register: remove_triggers_again
|
||||
|
||||
- name: assert results of remove all triggers (idempotent)
|
||||
assert:
|
||||
that:
|
||||
- not remove_triggers_again|changed
|
Loading…
Add table
Add a link
Reference in a new issue