Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Implementing DevOps with Ansible 2

You're reading from   Implementing DevOps with Ansible 2 A step-by-step guide to automating all DevOps stages with ease using Ansible

Arrow left icon
Product type Paperback
Published in Jul 2017
Publisher Packt
ISBN-13 9781787120532
Length 266 pages
Edition 1st Edition
Languages
Tools
Concepts
Arrow right icon
Author (1):
Arrow left icon
 McAllister McAllister
Author Profile Icon McAllister
McAllister
Arrow right icon
View More author details
Toc

Table of Contents (20) Chapters Close

Title Page
Credits
About the Author
Acknowledgments
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface
1. DevOps Fundamentals FREE CHAPTER 2. Configuration Management Essentials 3. Installing, Configuring, and Running Ansible 4. Playbooks and Inventory Files 5. Playbooks – Beyond the Fundamentals 6. Jinja in Ansible 7. Ansible Vault 8. Ansible Modules and Libraries 9. Integrating Ansible with CI and CD Solutions 10. Ansible and Docker 11. Extending Ansible 12. Ansible Galaxy

Ansible Handlers


Ansible handlers by default are run at the end of the actual execution of a playbook. They are different from registers in that they provide us with a way of creating a set of automation that can be executed once (and only once) at the end of a playbook based on a set of conditions provided during the execution. Logically, this could look something like the following:

  • Run role foo
  • Run role bar:
    • If role bar's service start failed, trigger a flag
  • Execute handlers:
    • If a trigger was flagged, do something

While this example may seem similar in some ways to conditionals, it is in many ways very different. That is to say, the handler would only get executed the one time regardless of how many times the flag was tripped. In addition, the other variance would be that a handler is more global in nature. That is to say, regardless of which role tripped the flag of the handler, it would still get executed, thus making the solution non-modular. Confused? Let's take a look at an example of...

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 $15.99/month. Cancel anytime
Visually different images