From 36ad9d3f0f5898ac680b2fd30a489a6c39693e2d Mon Sep 17 00:00:00 2001 From: David Wilson Date: Sun, 17 Sep 2017 05:26:45 +0530 Subject: [PATCH] Fixup ansible_demo.py for recent Ansibles --- examples/ansible_demo.py | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/examples/ansible_demo.py b/examples/ansible_demo.py index a243328d..50cf83d2 100644 --- a/examples/ansible_demo.py +++ b/examples/ansible_demo.py @@ -3,12 +3,9 @@ Minimal demo of running an Ansible module via mitogen. """ import json -import logging import time import mitogen -import mitogen.master -import mitogen.utils # Prevent accident import of an Ansible module from hanging on stdin read. import ansible.module_utils.basic @@ -95,16 +92,11 @@ def run_module(module, raw_params=None, args=None): def main(router): - fmt = '%(asctime)s %(levelname).1s %(name)s: %(message)s' - datefmt = '%H:%M:%S' - level = logging.DEBUG - level = logging.INFO - logging.basicConfig(level=level, format=fmt, datefmt=datefmt) - - context = mitogen.master.connect(broker) - print context.call(run_module, 'ansible.modules.core.system.setup') + context = router.local() + print context.call(run_module, 'ansible.modules.system.setup') for x in xrange(10): - print context.call(run_module, 'ansible.modules.core.commands.command', 'hostname') + print context.call(run_module, 'ansible.modules.commands.command', 'hostname') -if __name__ == '__main__' and mitogen.master: +if __name__ == '__main__' and mitogen.is_master: + import mitogen.utils mitogen.utils.run_with_router(main)