Last active
September 17, 2015 18:30
-
-
Save jamesandariese/0cc428949e0e4f5496ce to your computer and use it in GitHub Desktop.
Ansible: Higher Order Notification Handlers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
# Store the notification in a variable. We'll check it later. | |
# First, set the variable. We're using "blah". | |
- hosts: all | |
gather_facts: false | |
tasks: | |
- set_fact: blah=false | |
# Now do some other stuff. Use notify to get the same behavior as a normal handler. | |
# Alternatively, just use set_fact with when. They're equivalent. | |
- hosts: all | |
tasks: | |
- shell: "true" | |
notify: meta_notify | |
handlers: | |
- name: meta_notify | |
set_fact: blah=true | |
- hosts: all | |
tasks: | |
- shell: "true" | |
notify: meta_notify | |
handlers: | |
- name: meta_notify | |
set_fact: blah=true | |
# This needs to come after all the plays that can notify the handler. | |
# This can be wrapped in a role, too. | |
# The meta_notify handlers can also be wrapped in a dependent role in the meta/main.yml for roles that need it. | |
- hosts: all | |
tasks: | |
- debug: msg=hello | |
when: blah |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment