-
-
Save s-hertel/21325671c8cd24b1e8804f96affce872 to your computer and use it in GitHub Desktop.
This file contains 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
# ex: python generate_graph.py | dot -Tpng -o output_file.png | |
import yaml | |
edges = [] | |
def create_edges(stuff, parent): | |
if isinstance(stuff, str): | |
if parent != stuff: | |
edges.append((parent, stuff)) | |
elif isinstance(stuff, list): | |
for item in stuff: | |
create_edges(item, parent) | |
elif isinstance(stuff, dict): | |
for k, v in stuff.items(): | |
if k == 'description': # later | |
continue | |
create_edges(v, k) | |
create_edges(k, parent) | |
def main(): | |
data = yaml.load(open('gist.yaml')) | |
# create edges for Graphviz DOT, will fix later for component notation | |
for k, v in data.items(): | |
if v.get('tree'): | |
if len(v['tree']) == 1: | |
create_edges(v['tree'], parent=list(v['tree'].keys())[0]) | |
else: | |
create_edges(v['tree'], parent='top') | |
print('strict digraph tree {') | |
for row in edges: | |
print(' {0} -> {1};'.format(*row)) | |
print('}') | |
if __name__ == '__main__': | |
main() |
This file contains 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
Handlers: | |
lifecycle: | | |
Handlers from roles and tasks are loaded and combined in PlaybookExecutor.run. | |
The strategy handles the rest. It tracks the listening and notified handlers lists, determines | |
if the handlers notified exist, and executes the handlers at the end of a play or when | |
a flush_handlers meta task is provided, and waits on the results. | |
notes: | | |
This is unused code https://github.com/ansible/ansible/blob/651ea5da446887619f875e354903fe4df27b19f0/lib/ansible/executor/task_queue_manager.py#L229. | |
iterator._play.handlers is a list of handler block objects (one per play/role) | |
https://github.com/ansible/ansible/blob/651ea5da446887619f875e354903fe4df27b19f0/lib/ansible/plugins/strategy/__init__.py#L834. | |
Bug - as of 651ea5da446887619f875e354903fe4df27b19f0 handlers from the play override handlers from roles. | |
tree: | |
PlaybookCLI: | |
PlaybookExecutor_func_run: | |
Play_func_compile_roles_handlers: | |
description: load role handlers | |
Playbook_func__load_playbook_data: | |
description: load play handlers | |
TaskQueueManager_func_run: | |
StrategyModule_func_run: | |
StrategyBase_func__execute_meta: | |
description: check for flush_handlers | |
run_handlers: | |
_do_handler_run: | |
_queue_task: | |
TaskExecutor: | |
_execute: | |
description: set ansible_notify for result | |
_wait_on_handler_results: | |
_process_pending_results: | |
description: check for ansible_notify in each result item | |
search_handler_blocks_by_name: | |
Handler_func___init__: | |
Handler_func_notify_host: | |
StrategyBase_func_run: | |
run_handlers: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment