How to create a nicer pause...

252 visualizzazioni
Passa al primo messaggio da leggere

Krist van Besien

da leggere,
19 set 2016, 13:18:1019/09/16
a Ansible Project
Hi all,

In one of my playbooks I need to build in a fairly long pause.

So I have this task:

- name: Pause for 20 minutes
  pause: minutes=20

This works, but has the disadvantage that for 20 minutes nothing appears to happen on the screen. I would like to give a bit of feedback. Like a message "still waiting, x minutes to go" every 30 seconds or so. What would be the best way to do this?

Krist

Kai Stian Olstad

da leggere,
19 set 2016, 15:21:2519/09/16
a ansible...@googlegroups.com
It's not pretty, but it gives a feedback every 30 seconds.

- name: Pause
pause:
seconds=30
with_sequence: start=40 end=0 stride=-1

--
Kai Stian Olstad

Krist van Besien

da leggere,
21 set 2016, 08:09:3721/09/16
a Ansible Project, ansible-pr...@olstad.com

That works. But this is indeed not that pretty. Is there a way to get rid of the prompt?

I think I might in stead create a loop that just executes "sleep 30"...

Krist

Kai Stian Olstad

da leggere,
21 set 2016, 08:48:1221/09/16
a ansible...@googlegroups.com
No.


> I think I might in stead create a loop that just executes "sleep 30"...

This is a solution that looks nice, the downside is it does 40 includes
and creates 40 dummy tasks.


pause.yml
---
- name: "{{ item | int / 2 }} minutes left"
command: sleep 30
changed_when: false


In the playbook:

- include: pause.yml
with_sequence: start=40 end=1 stride=-1


--
Kai Stian Olstad

Josh Smift

da leggere,
21 set 2016, 09:04:5621/09/16
a ansible...@googlegroups.com
How about wait_for?

- name: count down forty 30-second intervals
wait_for: timeout=30
with_sequence: start=40 end=0 stride=-1

That gives me output like this:

TASK [count down forty 30-second intervals]
*************************************
ok: [localhost] => (item=40)
ok: [localhost] => (item=39)

etc.

-Josh (j...@care.com)

(apologies for the automatic corporate disclaimer that follows)

This email is intended for the person(s) to whom it is addressed and may contain information that is PRIVILEGED or CONFIDENTIAL. Any unauthorized use, distribution, copying, or disclosure by any person other than the addressee(s) is strictly prohibited. If you have received this email in error, please notify the sender immediately by return email and delete the message and any attachments from your system.
Rispondi a tutti
Rispondi all'autore
Inoltra
0 nuovi messaggi