I do this:

# first batch in parallel                                                   
                                                                    
    6 - hosts:                                                             
                                                                            
                         
    7   - apps_servers                                                     
                                                                            
                      
    8   max_fail_percentage: 1                                             
                                                                            
                         
    9   accelerate: false                                                   
                                                                            
                        
   10   sudo: true                                                         
                                                                            
                         
   11   gather_facts: true                                                 
                                                                            
                         
   12                                                                       
                                                                            
                        
   13   roles:                                                             
                                                                            
                         
   14   | - base            

# then one box at a time
 - hosts:                                                                   
                                                                            
                   
   26   - apps_servers                                                     
                                                                            
                      
   27   max_fail_percentage: 1                                             
                                                                            
                         
*   28   serial: 1                                                         
                                                                            
                          *
   29   accelerate: false                                                   
                                                                            
                        
   30   sudo: true                                                         
                                                                            
                         
   31   gather_facts: false                                                 
                                                                            
                        
   32                                                                       
                                                                            
                        
   33   pre_tasks:                                                         
                                                                            
                         
   34   - name: remove this host from the load balancer config             
                                                                            
                         
   35   | shell: ssh {{ item }} sudo manage-backend-servers {{ 
inventory_hostname }} remove                                               
                
   36   | with_items: groups['lb_servers']                                 
                                                                            
                         
   37   | sudo: false                                                       
                                                                            
                        
   38   | delegate_to: 127.0.0.1                                           
                                                                            
                         
   39                                                                       
                                                                            
                        
   40   roles:      
   43   | - apps        

   11   post_tasks:                                                         
                                                                            
                        
   10   - name: add this host back into the load balancer config           
                                                                            
                         
    9   | shell: ssh {{ item }} sudo manage-backend-servers {{ 
inventory_hostname }} add                                                   
           
    8   | sudo: false                                                       
                                                                            
                        
    7   | delegate_to: 127.0.0.1                                           
                                                                            
                         
    6   | with_items: groups['lb_servers']  

# then last batch in parallel again
  13 - hosts:                                                               
                                                                            
                       
   12   - apps_servers                                                     
                                                                            
                      
   11   max_fail_percentage: 1                                             
                                                                            
                         
   10   accelerate: false                                                   
                                                                            
                        
    9   sudo: true                                                         
                                                                            
                         
~   8   gather_facts: true                                                 
                                                                            
                         
    7                                                                       
                                                                            
                        
    6   roles:
    5   | - do_the_rest                                                     
                                                                            
                             
    4   | - finish_up                

On Monday, November 3, 2014 12:23:38 PM UTC, Brian Coca wrote:
>
> No, handlers run with the play settings, so you can do serial: 30% but 
> that will affect both the install and the handler. The other way to do it 
> is to separate it into 2 plays with different serial, but then they are not 
> really handlers.
>
> On Sat, Nov 1, 2014 at 8:46 AM, Costi Ciudatu <[email protected] 
> <javascript:>> wrote:
>
>> Is there a way to run the handlers with a different `serial` value than 
>> the rest of the play ?
>>
>> What I want is to install my services in large batches (usually, on all 
>> the machines at once) and if  any of those services needs to be restarted, 
>> I want to perform that operation on X machines at a time.
>> Ideally, the X value should be decided for each particular service: e.g. 
>> I want to restart postgresql instances one at a time and I want to restart 
>> nginx on 30% of the hosts at a time.
>> However, the installation needs to be done on all the machines in 
>> parallel, as I usually have no reason to do this sequentially (restarts are 
>> rarely required).
>>
>> Is this possible with handlers ? Or can I trigger handlers from a 
>> different play ?
>> Or, at least, is there some best practice recommendation for how to 
>> achieve this ?
>>
>> Thanks
>>
>>
>>  -- 
>> 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] <javascript:>.
>> To post to this group, send email to [email protected] 
>> <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/0b91eabf-d7aa-43d1-9056-154b9eb5ab54%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/ansible-project/0b91eabf-d7aa-43d1-9056-154b9eb5ab54%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
> Brian Coca
>  

-- 
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/0c43cae8-1986-47b1-85ca-3d47828bf4fe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to