WIndows: Alpha of built-in scheduled task support

Hi all,
There’s been some chatter about getting some sort of functionality for running tasks as scheduled jobs into the builtin powershell functions in Ansible.
I’ve spent a few hours today on a rought draft, and would really like some feedback.

The version I’m working on can be found in my fork here: https://github.com/trondhindenes/ansible/blob/async_test/lib/ansible/module_utils/powershell.ps1
(The whole fork is being kept up to date from ansible:devel, so just cloning the fork and running hacking/env-setup is probably the easist way to test it)

As for writing modules which support scheduled tasks, here’s an example:
https://gist.github.com/trondhindenes/d679a6a427d74d72dfd7

In short, everything inside the “$IsScheduledJob -eq $true” block will execute as a scheduled job, along with everything before.
Anything inside the “else” block will run during the “regular” execution which Ansible does, which will happen after the scheduled job has completed. This means that this block is responsible for parsing the result of
the scheduled job, and returning that down to Ansible. I’ve created a helper function for that ($job in my example), which outputs an object containing result (success/failure) and the output object from the scheduled task (generated from exit-json/fail-json during scheduled task execution).

From what I can see it’s looking good, so I’d really like to get some feedback on this!

-Trond

Will try to poke at this later this week- trying to knock out some customer stuff right now…

I can try this out. What are you thinking the expected use case for this would be?

The intention is to have a method/framework for creating Ansible modules which require running as scheduled tasks (automating Windows Update os one example).