diff --git a/changelogs/fragments/167-win_scheduled_task_stat-check_mode.yml b/changelogs/fragments/167-win_scheduled_task_stat-check_mode.yml new file mode 100644 index 00000000..5b1d7a5c --- /dev/null +++ b/changelogs/fragments/167-win_scheduled_task_stat-check_mode.yml @@ -0,0 +1,2 @@ +minor_changes: + - win_scheduled_task_stat - add check mode support (https://github.com/ansible-collections/community.windows/pull/167) diff --git a/plugins/modules/win_scheduled_task_stat.ps1 b/plugins/modules/win_scheduled_task_stat.ps1 index 37bc78a2..2a640136 100644 --- a/plugins/modules/win_scheduled_task_stat.ps1 +++ b/plugins/modules/win_scheduled_task_stat.ps1 @@ -7,7 +7,7 @@ #Requires -Module Ansible.ModuleUtils.Legacy #Requires -Module Ansible.ModuleUtils.SID -$params = Parse-Args -arguments $args +$params = Parse-Args -arguments $args -supports_check_mode $true $_remote_tmp = Get-AnsibleParam $params "_ansible_remote_tmp" -type "path" -default $env:TMP $path = Get-AnsibleParam -obj $params -name "path" -type "str" -default "\" diff --git a/tests/integration/targets/win_scheduled_task_stat/tasks/main.yml b/tests/integration/targets/win_scheduled_task_stat/tasks/main.yml index a87e61a6..836a450d 100644 --- a/tests/integration/targets/win_scheduled_task_stat/tasks/main.yml +++ b/tests/integration/targets/win_scheduled_task_stat/tasks/main.yml @@ -14,6 +14,18 @@ state: absent # folder stat tests + +# check_mode operation test +- name: check_mode - get stat of a folder that is missing + win_scheduled_task_stat: + path: '{{test_scheduled_task_stat_path}}' + register: stat_folder_missing + check_mode: True + +- name: assert that check_mode works + assert: + that: stat_folder_missing is not skipped + - name: get stat of a folder that is missing win_scheduled_task_stat: path: '{{test_scheduled_task_stat_path}}'