Took a long time to answer, but that might work. We have now found much 
better way of working with roles, so the dependency of the task that the 
playbook need to reach before, has been eliminated. But that does not mead 
we won't have the problem in the future. Thanks!

Den måndag 14 augusti 2017 kl. 19:09:35 UTC+2 skrev J Hawkesworth:
>
> I suppose use you could modify your playbook so that after the task that 
> all the other machines must wait for, ansible creates a file on the 
> controller machine.  Then the next step in the playbook would use wait_for, 
> delegated to the controller so the other machines would have to wait until 
> the file was written before continuing to the next tasks.
>
> Hope this helps,
>
> Jon
>
>
> On Wednesday, August 2, 2017 at 7:01:30 PM UTC+1, Marcus Karlsson wrote:
>>
>> I can see how my explanation of my problems seems a bit confusing. I'll 
>> try again:
>>
>> As you said, my title is a bit of as well. We have several playbooks in 
>> our setup, but, my problem is only considering ONE playbooks with one role. 
>> The play run on more then one host.
>> One of the tasks in that play, is to only perform action on one of those 
>> hosts. We solved that by having a task in the play only perfoming the 
>> action and give that host a list of all the hosts if the count was 0, 
>> otherwise it would still perform the task but the host got an empty list.
>>
>> Sadly,I dont have access to that specific code right now since im on a 
>> diffrent project. But the problem per say, is that the plays run 
>> simultaniously on all hosts but without garantuee on which play on the host 
>> will be done first. Since the task is give the host with count 0 a list of 
>> all the hosts, the play might fail if the play on that hosts reaches that 
>> task before all of the other hosts are done. 
>>
>> We have done simple solution, but still dirty, where we split that 
>> playbook up in to two playbooks, where the second playbook start of with 
>> the task of assining the list of the hosts. Since we have to run the first 
>> playbook, we can garantuee that the första playbook will be done and the 
>> list of hosts exists. So, that is why my question arose: Is there any way 
>> to have condition on a tasks in a play, that runs on multiple hosts 
>> simultaniously, similar to "stop and wait for the other plays"?
>>
>> I know that the answer to the question probably is NO, since the play is 
>> not aware of each other.
>>
>> Den torsdag 6 juli 2017 kl. 18:48:47 UTC+2 skrev Kai Stian Olstad:
>>>
>>> On 05. juli 2017 16:20, Marcus Karlsson wrote: 
>>> > In my project, where we install Splunk with the help of terraform and 
>>> > ansible, we ran into some "errors" where we had the ansible playbook 
>>> run on 
>>> > 3 hosts installing a search head in Splunk. 
>>>
>>> I'm a bit confused. 
>>> Here you describe one playbook with 3 hosts, but you subject has 
>>> parallel paybooks, aka more than one playbook. 
>>>
>>>
>>> > On of the tasks were to 
>>> > configure one of these hosts as a captain. In this case, the task was 
>>> given 
>>> > a list on members of a cluster if the count was 0, otherwise it was 
>>> given 
>>> > an empty list. The problem was that since there is no garantuee that 
>>> the 
>>> > playbooks will finish at the same time, that task got excecuted before 
>>> the 
>>> > other cluster members were up and running (restarting them in some of 
>>> the 
>>> > tasks). So, our solution was to break out that task into a new 
>>> playbook 
>>> > (which seams like half arsed solution in a way, but it worked). 
>>>
>>> This is also somewhat confusing I think we need defined what is what. 
>>>
>>> A playbook is a yaml-file. This playbook can have multiple plays. 
>>>
>>> playbook.yml 
>>> -- 
>>> - name: This is one play 
>>>    hosts: all 
>>>    tasks: 
>>>      - debug: msg="Test" 
>>>
>>> - name: This is another play 
>>>    hosts: all 
>>>    tasks: 
>>>      - debug: msg="Test" 
>>>
>>> This file is one playbook with two plays. 
>>>
>>> Default Ansible run first task on all the host, when that task is 
>>> finished it run the next task on all the hosts.... 
>>>
>>>
>>> > Have I missed something in ansible documentation about some task or 
>>> module 
>>> > that handles this kind of problem? Like a hold_and_wait for condition? 
>>> > Is there a way to let playbooks run in parallell with each other, but 
>>> with 
>>> > a condition to continue if all playbooks reach a specific task and 
>>> then 
>>> > continue? 
>>>
>>> Ansible has modules that does wait, but hard to recommend since I don't 
>>> understand you problem. 
>>>
>>>
>>> > I dont know if this was the best explanation of the problem but, ask 
>>> if 
>>> > there is any uncertanties in what I mean! 
>>>
>>> Maybe it's time to show some code that might explain the problem more 
>>> easily. 
>>>
>>> -- 
>>> Kai Stian Olstad 
>>>
>>

-- 
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/d12df418-cea6-4e9a-829f-2a426e508534%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to