Condition Pauses?

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.

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.

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.

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.

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

+1 to this

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.