[Urgent help] Running a task every x seconds till y seconds

Hi All,

I there a way to run a task every x seconds, store the output. The task should run till y second. Example, I would like to run a task every 10 seconds , get the output , till 300 seconds. So the task would be run 30 times and all 30 outputs are avilable

Thanks,
Akash

Hi

You can achieve this as follows

  • hosts: localhost
    tasks:
  • include: action.yml
    with_items:
  • 1
  • 2
  • 3

in action.yml

  • name: “Wait for 10 seconds”
    wait_for: timeout=10

  • name: “run task after 10 seconds”
    command: uptime