2017-09-20 00:28:03 +00:00
|
|
|
# these are the older tests that test out the deprecated args, keep here until
|
|
|
|
# the new changes are more bedded down
|
|
|
|
---
|
2017-03-15 14:11:24 +00:00
|
|
|
- name: Remove potentially leftover scheduled task
|
|
|
|
win_scheduled_task: &wst_absent
|
2017-03-24 02:42:12 +00:00
|
|
|
name: Ansible Test
|
2017-03-15 14:11:24 +00:00
|
|
|
state: absent
|
|
|
|
|
2017-03-24 02:42:12 +00:00
|
|
|
|
2017-03-15 14:11:24 +00:00
|
|
|
- name: Add scheduled task
|
|
|
|
win_scheduled_task: &wst_present
|
2017-03-24 02:42:12 +00:00
|
|
|
name: Ansible Test
|
2017-03-15 14:11:24 +00:00
|
|
|
executable: dir.exe
|
|
|
|
arguments: C:\Windows\Temp\
|
|
|
|
frequency: once
|
|
|
|
time: 5pm
|
|
|
|
user: SYSTEM
|
|
|
|
register: add_scheduled_task
|
|
|
|
|
2017-03-24 02:42:12 +00:00
|
|
|
- name: Test add_scheduled_task
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- add_scheduled_task.changed == true
|
|
|
|
|
|
|
|
|
2017-03-15 14:11:24 +00:00
|
|
|
- name: Add scheduled task (again)
|
|
|
|
win_scheduled_task: *wst_present
|
|
|
|
register: add_scheduled_task_again
|
|
|
|
|
2017-03-24 02:42:12 +00:00
|
|
|
- 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
|
|
|
|
|
|
|
|
|
2017-03-15 14:11:24 +00:00
|
|
|
- name: Remove scheduled task
|
|
|
|
win_scheduled_task: *wst_absent
|
|
|
|
register: remove_scheduled_task
|
|
|
|
|
2017-03-24 02:42:12 +00:00
|
|
|
- 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
|
|
|
|
|
|
|
|
|
2017-03-15 14:11:24 +00:00
|
|
|
- name: Remove scheduled task (again)
|
|
|
|
win_scheduled_task: *wst_absent
|
|
|
|
register: remove_scheduled_task_again
|
2017-03-24 02:42:12 +00:00
|
|
|
|
|
|
|
- name: Test remove_scheduled_task_again
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- remove_scheduled_task_again.changed == false
|
2017-06-14 07:02:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
# 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:
|
2017-09-20 00:28:03 +00:00
|
|
|
- add_scheduled_task_new_path_1|changed
|
2017-06-14 07:02:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
- 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:
|
2017-09-20 00:28:03 +00:00
|
|
|
- add_scheduled_task_new_path_2|changed
|
2017-06-14 07:02:36 +00:00
|
|
|
when: not in_check_mode
|
|
|
|
|
|
|
|
- name: Test add_scheduled_task_new_path_2 (check-mode)
|
|
|
|
assert:
|
|
|
|
that:
|
2017-09-20 00:28:03 +00:00
|
|
|
- add_scheduled_task_new_path_2|changed
|
2017-06-14 07:02:36 +00:00
|
|
|
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:
|
2017-09-20 00:28:03 +00:00
|
|
|
- remove_scheduled_task_new_path_2|changed
|
2017-06-14 07:02:36 +00:00
|
|
|
when: not in_check_mode
|
|
|
|
|
|
|
|
- name: Test remove_scheduled_task_new_path_2 (check-mode)
|
|
|
|
assert:
|
|
|
|
that:
|
2017-09-20 00:28:03 +00:00
|
|
|
- not remove_scheduled_task_new_path_2|changed
|
2017-06-14 07:02:36 +00:00
|
|
|
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:
|
2017-09-20 00:28:03 +00:00
|
|
|
- remove_scheduled_task_new_path_1|changed
|
2017-06-14 07:02:36 +00:00
|
|
|
when: not in_check_mode
|
|
|
|
|
|
|
|
- name: Test remove_scheduled_task_new_path_1 (check-mode)
|
|
|
|
assert:
|
|
|
|
that:
|
2017-09-20 00:28:03 +00:00
|
|
|
- not remove_scheduled_task_new_path_1|changed
|
2017-06-14 07:02:36 +00:00
|
|
|
when: in_check_mode
|
2017-07-10 04:18:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
# 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
|