On 05/15/14 17:25, Michael Peters wrote:
> On Wed, May 14, 2014 at 6:15 PM, Michael DeHaan <[email protected]> wrote:
>> The multiple play method is correct because the tasks would not be executed
>> for every host in the host loop.
> Well, then maybe I'm doing it wrong. How do you tell a play to just
> execute on one host in the host loop?
> Right now I run the "critical section" play with a serial of 1 and try
> to leave some indicator that it was run  (which is sometimes harder
> than others) and then the subsequent hosts skip the tasks in the place
> after they detect they weren't the first to try.
>
> So my approach is still wasteful since I know ahead of time that it's
> only ever going to run once but every host in the loop besides the
> first one has to detect the skip condition and skip every task in
> serial.
>
>> Pause is a bit of an exception.
> Does it have to be an exception? Can we expose that functionality to
> other tasks or plays? I'd be willing to help with coding something if
> you think it's worth it.
>

If a play acts on all hosts in 'somegroup' group, you can restrict a
task in that play to run only on the first host in the group by adding
the following conditional:

when: inventory_hostname == groups["somegroup"][0]

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/5374DE51.7070801%40yahoo.gr.
For more options, visit https://groups.google.com/d/optout.

Reply via email to