Mimic "now + time" in schedule state - SaltStack

SaltStack has a schedule state that allows you to manage scheduled jobs on client (Minion), and it's very handy to manage cron style job.

But sometimes you could need to run a job once, in other words, like "at" command not like a cronjob.

OK! There is good news and there is bad news :D
The good news is that SaltStack schedule state supports "run once", so a job can be run just for one time.

The bad news is that to do that you need to specify the date explicitly in ISO 8601 date format by default (but you can change it), e.g. "2017-02-05T19:00:00".
i.e. it doesn't support the style of "at" command like "now +1 min".

I couldn't found any standard way to do that, but I found a workaround using Jinja2 filters to achieve that goal.
It simply generates "now" based on Unix Time, then it add x number of minutes, finally it converts that to ISO8601 time.

(None|strftime("%s")|int + 1)|strftime("%Y-%m-%dT%H:%M:%S")

So let's see that in action, this a dummy example how to run ping job after 1 minute from now.

{% set timer = cfg.get('timer', 1)|int %}

    - function: test.ping
    - once: "{{ (None|strftime("%s")|int + timer)|strftime("%Y-%m-%dT%H:%M:%S") }}"
    - once_fmt: "%Y-%m-%dT%H:%M:%S"
    - persist: False

The "at" state or "at" module could be used to, but that totally depends on what you need to do. For example you can run other states from schedule state but just system commands from "at" state/module.


  1. Aside from 바카라사이트 traditional casino games, KAL Hotel and Casino also supply different multi-line video slots, reel slots, and video poker machines. That’s an bold program that could attract each Korean and foreign guests for something other than gaming. Being a three hour drive from the nearest international airport and major population middle severely constrains Kangwon Land’s potential. Sponsorship of the Olympics and exposure through the games hasn’t supplied a bump among foreign guests, comprising simply over 1% of whole customers before and after the games.

  2. This machine creates high decision, high energy plastic elements. The Form 2 3D printer, developed by Formlabs, is a stereolithography machine that creates elements using liquid plastic that is solidified layer by layer using UV light. When designing go cool towels a 3D mannequin, it's only prudent assume of|to assume about|to consider} the precise filament material you intend to make use of. For instance, the thermal growth coefficient of a plastic will have to be thought-about when deciding on the decision and tolerances of a 3D mannequin.


Powered by Blogger.

Hello, my name is Ahmed AbouZaid and this is my "lite" technical blog!

I'm a passionate DevOps engineer, Cloud/Kubernetes specialist, Free/Open source geek, and an author.

I believe in self CI/CD (Continuous Improvements/Development), also that "the whole is greater than the sum of its parts".

DevOps transformation, automation, data, and metrics are my preferred areas. And I like to help both businesses and people to grow.

Popular Posts