mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-23 05:10:22 -07:00
Allow win_scheduled_task to support adding and removing task paths (#24025)
* allows win_scheduled_task to support adding and removing task paths * fix line length for documentation * added integration tests for path creation and removal * removing ability to remove TaskPath if a task isn't removed. also removed superfluous line of code in Invoke-TaskPathCheck function
This commit is contained in:
parent
cf30b162a9
commit
91e995d691
3 changed files with 161 additions and 5 deletions
|
@ -123,3 +123,91 @@
|
|||
that:
|
||||
- remove_scheduled_task_again.changed == false
|
||||
- remove_scheduled_task_again.exists == 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.msg == 'Added new task Ansible Test New Path 1 and task path \\non_existent_path\\ created'
|
||||
|
||||
|
||||
- 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.msg == 'Added new task Ansible Test New Path 2'
|
||||
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'
|
||||
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.msg == 'Deleted task Ansible Test New Path 2'
|
||||
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'
|
||||
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.msg == 'Deleted task Ansible Test New Path 1 and task path \\non_existent_path\\ removed'
|
||||
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'
|
||||
when: in_check_mode
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue