# Condition Pauses?

**URL:** <https://forum.ansible.com/t/condition-pauses/12321>\
**Category:** Ansible Project\
**Created:** [February 10, 2013, 1:48am UTC](https://forum.ansible.com/t/condition-pauses/12321 "2013-02-10T01:48:05Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![fdavis](https://avatars.discourse-cdn.com/v4/letter/f/a698b9/32.png) [@fdavis](https://forum.ansible.com/u/fdavis)\
**Post date:** [February 10, 2013, 1:48am UTC](https://forum.ansible.com/t/condition-pauses/12321/1 "2013-02-10T01:48:05Z")

</div>

The other day we noticed that the Pause module is unconditional. only\_if/when\_\* don’t effect its being used or not.

I believe that this is related to its “BYPASS HOST LOOP” behaviour.  
(Being that it bypasses the host loop, and the conditional logic therein.)  
We weren’t sure if that was intentional or not, but I thought I’d bring it up.  
I don’t know of a reason where it would hurt to pause when it wasn’t required,  
especially since you can abort/continue if you need to. (unless its running automatically)

Part of the reason I bring this up, is because I remember mention of a “local\_host\_once” type of action.  
I would assume that it would also “BYPASS HOST LOOP”, and breaking conditional execution there could be hazardous.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [February 10, 2013, 2:52am UTC](https://forum.ansible.com/t/condition-pauses/12321/2 "2013-02-10T02:52:04Z")

</div>

Assume you have 500 hosts and are updating all of them at once.

You have a pause step that says "Ok, are you ready to proceed? Be  
sure the room with the laser is free of humans as they will get  
vaporized!!!"

You don't want it to pause once for each host between steps, just the one time.

That's why it is BYPASS\_HOST\_LOOP in the code.

If you want a pause that is NOT that way, we need a different kind of  
pause module, and one that is non-interactive. I would recommend  
building one just called "sleep" in which case it could still be a  
server side module -- and docs could mention this appropriately.

In many cases, wait\_for is also a decent choice.

---

<div class="post-metadata">

**Author:** ![fdavis](https://avatars.discourse-cdn.com/v4/letter/f/a698b9/32.png) [@fdavis](https://forum.ansible.com/u/fdavis)\
**Post date:** [February 10, 2013, 5:11am UTC](https://forum.ansible.com/t/condition-pauses/12321/3 "2013-02-10T05:11:30Z")

</div>

Ah, okay.

I was using pause for injecting a little time inbetween tasks to  
avoid failing out because the previous command hadn’t completely  
started/stopped the processes it was supposed to.

I could try using wait\_for. Its just less intuitive because  
we wouldn’t actually waiting for wait\_for to poll a service.

Writing a module to sleep that way seems pointless,  
it would be about equivalent to

- local\_action: command sleep $time\_amount

I think the misunderstanding with pause, is that the when  
or only\_if conditional is based on variables stored per host.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [February 10, 2013, 2:42pm UTC](https://forum.ansible.com/t/condition-pauses/12321/4 "2013-02-10T14:42:58Z")

</div>

> Writing a module to sleep that way seems pointless,  
> it would be about equivalent to  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- local\_action: command sleep $time\_amount

Disagree, actually.

Having more readable playbooks is totally \*NOT\* pointless to me,  
because it improves readability and makes things faster to write.

I think it's kind of important.

Ansible is a description of a system or process, and a way to make  
that complex process simpler.

---

<div class="post-metadata">

**Author:** ![Tim\_Bielawa](https://avatars.discourse-cdn.com/v4/letter/t/ed8c4c/32.png) [@Tim\_Bielawa](https://forum.ansible.com/u/Tim_Bielawa)\
**Post date:** [February 10, 2013, 5:34pm UTC](https://forum.ansible.com/t/condition-pauses/12321/5 "2013-02-10T17:34:08Z")

</div>

+1 to this

---

<div class="post-metadata">

**Author:** ![fdavis](https://avatars.discourse-cdn.com/v4/letter/f/a698b9/32.png) [@fdavis](https://forum.ansible.com/u/fdavis)\
**Post date:** [February 12, 2013, 12:26am UTC](https://forum.ansible.com/t/condition-pauses/12321/6 "2013-02-12T00:26:37Z")

</div>

> > Writing a module to sleep that way seems pointless,  
> > it would be about equivalent to
> > 
> > - local\_action: command sleep $time\_amount
> 
> Disagree, actually.
> 
> Having more readable playbooks is totally _NOT_ pointless to me,  
> because it improves readability and makes things faster to write.
> 
> I think it’s kind of important.

Hmm… I think I’ll disagree with myself here as well.  
Ansible’s readability is amazing. I’ll keep that in mind in the future.  
You’re quite right, as having a module support that would make the same  
command take half the number (or less) of characters as what I just wrote.

I was wondering though, maybe the module I seek is something  
that behaves like wait\_for, but could poll for different status, such as  
a particular process starting/stopping.

I think such a module would work better with the testing idea from another thread.  
You could specify a certain number of attempts or a timeout,  
kind of like Nagios checks, before you give up and assume failure.
