Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Mastering Ansible, Second Edition

You're reading from   Mastering Ansible, Second Edition Master the ins and outs of advanced operations with Ansible

Arrow left icon
Product type Paperback
Published in Mar 2017
Publisher Packt
ISBN-13 9781787125681
Length 310 pages
Edition 2nd Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Jesse Keating Jesse Keating
Author Profile Icon Jesse Keating
Jesse Keating
Arrow right icon
View More author details
Toc

Serializing single tasks


Certain applications that run multiple copies of a service may not react well to all of those services being restarted at once. Typically, when upgrading this type of application, a serial play is used. However, if the application is of large enough scale, serializing the entire play may be wildly inefficient. A different approach can be used, which is to serialize just the sensitive task(s), often the handlers to restart services.

To serialize a specific handler task, we can make use of a built in variable, play_hosts. This variable holds the list of hosts that should be used for a given task, as part of the play. It is kept up to date with hosts that have failed or are unreachable. Using this variable, we can construct a loop to iterate over each host that could potentially run a handler task. Instead of using the item in the module arguments, we'll use the item in when conditional and a delegate_to directive, so that we can run the handler task if the host notified...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime