at module -- doesn't schedule at a specific time?

Greetings.

I’m looking at the documentation for the at module, and as far as I can tell, the module will only schedule a job based on “now + time-delta”.

Am I missing something? How can I use this module (or perhaps a different module) to schedule a job at 2300 ?

Thanks.

–EbH

You can come close to 23:00 (+- 30 seconds) with this
   {{ ((lookup('pipe', 'date --date 23:00 +%s') | int - lookup('pipe', 'date +%s') | int) / 60) | round | int }}
and units set to minutes.

An alternative is to run the at command with the shell module.

There are at least two ways I can think of, but I’ve never used the module myself.

The first is to calculate the necessary delta from the current time, then invoke the module with the calculated delta.

The second is to write a script that runs the real “at” utility (which accepts absolute times) and run the script instead of using the at module.

This stackoverflow article covers exactly your question, and includes a link to a modified at module that might be useful:

https://stackoverflow.com/questions/41760349/schedule-command-at-specific-time-with-ansible

And/or you could advise the authors of the current at module of your wish; the module is still in preview, and it would be a useful feature to have.

Thank you both for the suggestions. And thanks for the pointer to the modified module. I’m not sure I’m allowed to install it, but maybe I can find a machine to try it out on.

I’ve actually decided for a few reasons that, in this particular case, a shell script will work better than an ansible playbook. But I will keep your ideas in mind the next time this comes up.

I’ve also submitted a feature request to the github thing.