mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-24 22:00:22 -07:00
win_scheduled_task: Add enhanced run option support (#24174)
* add enhanced run option support for win_scheduled_task * changed run_level option to runlevel * correct merge conflicts since task path fix * changed run_level option to runlevel * changed do_not_store_password to store_password, and other minor fixes * conditional logic swap, and documentation change for password
This commit is contained in:
parent
52c1a1936d
commit
7d3951d065
3 changed files with 215 additions and 7 deletions
|
@ -211,3 +211,124 @@
|
|||
that:
|
||||
- remove_scheduled_task_new_path_1.msg == 'Task does not exist'
|
||||
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
|
||||
- add_scheduled_task_run_options_1.exists == false
|
||||
|
||||
|
||||
- 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
|
||||
- change_scheduled_task_run_options_user.exists == 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
|
||||
- change_scheduled_task_run_options_user_again.exists == true
|
||||
|
||||
|
||||
- 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
|
||||
- change_scheduled_task_run_options_runlevel.exists == 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
|
||||
- change_scheduled_task_run_options_runlevel_again.exists == true
|
||||
|
||||
|
||||
# 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
|
||||
- change_scheduled_task_run_options_store_password.exists == true
|
||||
|
||||
|
||||
- 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
|
||||
- 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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue