Tuesday, April 16, 2019

Ansible Playbook: Generate multiple files at specific time interval

In the previous post, we have seen how to generate multiple files using with_sequence and loop features.

Here, we will introduce the delay functionality in the loop feature. This will give a pause after every iteration. So, each file will be created at specific time interval. Let's say, we will create 20 files at 10sec time interval.
Download the yml file [generateFiles_pattern_withDelay.yml]

--- 
- hosts: localhost
  gather_facts: no
  become: no
  tasks:
    - name: create 20 empty file in each 10 sec
      file:
        path: "/tmp/playing_opera/loopdemo/file{{ item }}"
        state: touch
      with_sequence: start=1 end=20
      loop_control:
        pause: 10
...



Next: ..?? Not yet decided :)





No comments:

Post a Comment