ansible-collections / community.windows

Windows community collection for Ansible
https://galaxy.ansible.com/community/windows
GNU General Public License v3.0
199 stars 154 forks source link

win_scheduled_task: Not possible to create idle task #25

Open jborean93 opened 4 years ago

jborean93 commented 4 years ago

From @dagwieers on Oct 17, 2018 22:27

SUMMARY

The module does not seem to support idle tasks with a set idle time to execute, the default idle time used seems to be set to 10 minutes.

ISSUE TYPE
COMPONENT NAME

win_scheduled_task

ANSIBLE VERSION

v2.8

OS / ENVIRONMENT

Windows 10 targets

STEPS TO REPRODUCE

In Windows you can create an "idle" action with a specific idle time, e.g. 30 minutes and backoff period.

We need to enforce log off of a local user after 30 mins of idle time on shared public computers.

Related info: https://superuser.com/questions/777488/task-scheduler-what-is-wait-for-idle-for

Copied from original issue: ansible/ansible#47251

mcflux commented 3 years ago

This is still a missing feature in that module. Usually you can have triggers and conditions as well. Like daily, but only when computer idle for 10 minutes.

Or is there a solution to that problem yet?

Qu3uk commented 3 years ago

I came across this today as I had a use case for an idle trigger which fired after more than 10 minutes.

I see this isn't implemented as per the TODO entries in the module.

https://github.com/ansible-collections/community.windows/blob/2f44889a6b098dced7c1ef725740b7bd0c245c0c/plugins/modules/win_scheduled_task.ps1#L53

However the larger issue would appear to be the IdleDuration and WaitTimeout which are part of the settings object (IdleSettings) and required for this function appear to be deprecated by M$ suggesting this is no longer possible anyway.

[https://docs.microsoft.com/en-us/windows/win32/taskschd/idlesettings](IdleSettings Documentation)

mcflux commented 3 years ago

Can this maybe also achieved by observing a certain event? Tried to find an event that signalizes idle state, couldnt come up with one, only the "logg off" and this is not the same since logoff is only triggered of the idle state.