Skip to content

Instantly share code, notes, and snippets.

@chrismeyersfsu
Last active March 1, 2021 18:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrismeyersfsu/e2f60d96e53c821091fac0babaa69239 to your computer and use it in GitHub Desktop.
Save chrismeyersfsu/e2f60d96e53c821091fac0babaa69239 to your computer and use it in GitHub Desktop.
Randomly sleep
---
- hosts: all
gather_facts: false
vars:
sleep_time: 120
tasks:
- name: sleep
shell: sleep {{ sleep_time }}
---
- hosts: all
gather_facts: false
vars:
sleep_min: 120
sleep_max: 150
tasks:
- name: decide sleep time
command: shuf -i {{ sleep_min }}-{{ sleep_max }} -n1
register: result
- name: save sleep time
set_fact:
sleep_seconds: "{{ result.stdout_lines[0] }}"
- name: output sleep time
debug:
msg: "will sleep for {{ sleep_seconds }} seconds"
- name: save sleep time to artifact data
set_stats:
data:
sleep_seconds_value: "{{ sleep_seconds }}"
- name: sleep
command: sleep {{ sleep_seconds }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment