diff --git a/LICENSE b/LICENSE index 61d21fee..70e43a94 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright 2017, David Wilson +Copyright 2019, David Wilson Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/ansible_mitogen/affinity.py b/ansible_mitogen/affinity.py index d7ae45a6..bcab89af 100644 --- a/ansible_mitogen/affinity.py +++ b/ansible_mitogen/affinity.py @@ -1,4 +1,4 @@ -# Copyright 2017, David Wilson +# Copyright 2019, David Wilson # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/ansible_mitogen/connection.py b/ansible_mitogen/connection.py index 7bae8c25..254a4286 100644 --- a/ansible_mitogen/connection.py +++ b/ansible_mitogen/connection.py @@ -1,4 +1,4 @@ -# Copyright 2017, David Wilson +# Copyright 2019, David Wilson # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/ansible_mitogen/loaders.py b/ansible_mitogen/loaders.py index 08c59278..ff06c0c5 100644 --- a/ansible_mitogen/loaders.py +++ b/ansible_mitogen/loaders.py @@ -1,4 +1,4 @@ -# Copyright 2017, David Wilson +# Copyright 2019, David Wilson # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/ansible_mitogen/logging.py b/ansible_mitogen/logging.py index 97832938..e2035254 100644 --- a/ansible_mitogen/logging.py +++ b/ansible_mitogen/logging.py @@ -1,4 +1,4 @@ -# Copyright 2017, David Wilson +# Copyright 2019, David Wilson # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: @@ -75,25 +75,28 @@ class Handler(logging.Handler): def setup(): """ - Install a handler for Mitogen's logger to redirect it into the Ansible - display framework, and prevent propagation to the root logger. + Install handlers for Mitogen loggers to redirect them into the Ansible + display framework. Ansible installs its own logging framework handlers when + C.DEFAULT_LOG_PATH is set, therefore disable propagation for our handlers. """ - logging.getLogger('ansible_mitogen').handlers = [Handler(display.vvv)] - mitogen.core.LOG.handlers = [Handler(display.vvv)] - mitogen.core.IOLOG.handlers = [Handler(display.vvvv)] - mitogen.core.IOLOG.propagate = False + l_mitogen = logging.getLogger('mitogen') + l_mitogen_io = logging.getLogger('mitogen.io') + l_ansible_mitogen = logging.getLogger('ansible_mitogen') + + for logger in l_mitogen, l_mitogen_io, l_ansible_mitogen: + logger.handlers = [Handler(display.vvv)] + logger.propagate = False if display.verbosity > 2: - mitogen.core.LOG.setLevel(logging.DEBUG) - logging.getLogger('ansible_mitogen').setLevel(logging.DEBUG) + l_ansible_mitogen.setLevel(logging.DEBUG) + l_mitogen.setLevel(logging.DEBUG) else: # Mitogen copies the active log level into new children, allowing them # to filter tiny messages before they hit the network, and therefore # before they wake the IO loop. Explicitly setting INFO saves ~4% # running against just the local machine. - mitogen.core.LOG.setLevel(logging.ERROR) - logging.getLogger('ansible_mitogen').setLevel(logging.ERROR) + l_mitogen.setLevel(logging.ERROR) + l_ansible_mitogen.setLevel(logging.ERROR) if display.verbosity > 3: - mitogen.core.IOLOG.setLevel(logging.DEBUG) - logging.getLogger('ansible_mitogen').setLevel(logging.DEBUG) + l_mitogen_io.setLevel(logging.DEBUG) diff --git a/ansible_mitogen/mixins.py b/ansible_mitogen/mixins.py index 7a180952..5f51cc6f 100644 --- a/ansible_mitogen/mixins.py +++ b/ansible_mitogen/mixins.py @@ -1,4 +1,4 @@ -# Copyright 2017, David Wilson +# Copyright 2019, David Wilson # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/ansible_mitogen/module_finder.py b/ansible_mitogen/module_finder.py index 56e8b82e..633e3cad 100644 --- a/ansible_mitogen/module_finder.py +++ b/ansible_mitogen/module_finder.py @@ -1,4 +1,4 @@ -# Copyright 2017, David Wilson +# Copyright 2019, David Wilson # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/ansible_mitogen/parsing.py b/ansible_mitogen/parsing.py index fa79282a..525e60cf 100644 --- a/ansible_mitogen/parsing.py +++ b/ansible_mitogen/parsing.py @@ -1,4 +1,4 @@ -# Copyright 2017, David Wilson +# Copyright 2019, David Wilson # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/ansible_mitogen/planner.py b/ansible_mitogen/planner.py index f3e4500e..3c5bd64f 100644 --- a/ansible_mitogen/planner.py +++ b/ansible_mitogen/planner.py @@ -1,4 +1,4 @@ -# Copyright 2017, David Wilson +# Copyright 2019, David Wilson # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/ansible_mitogen/plugins/action/mitogen_get_stack.py b/ansible_mitogen/plugins/action/mitogen_get_stack.py index ed7520cf..12afbfba 100644 --- a/ansible_mitogen/plugins/action/mitogen_get_stack.py +++ b/ansible_mitogen/plugins/action/mitogen_get_stack.py @@ -1,4 +1,4 @@ -# Copyright 2017, David Wilson +# Copyright 2019, David Wilson # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/ansible_mitogen/plugins/connection/mitogen_doas.py b/ansible_mitogen/plugins/connection/mitogen_doas.py index 873b0d9d..1113d7c6 100644 --- a/ansible_mitogen/plugins/connection/mitogen_doas.py +++ b/ansible_mitogen/plugins/connection/mitogen_doas.py @@ -1,4 +1,4 @@ -# Copyright 2017, David Wilson +# Copyright 2019, David Wilson # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/ansible_mitogen/plugins/connection/mitogen_docker.py b/ansible_mitogen/plugins/connection/mitogen_docker.py index 5904c83e..b71ef5f1 100644 --- a/ansible_mitogen/plugins/connection/mitogen_docker.py +++ b/ansible_mitogen/plugins/connection/mitogen_docker.py @@ -1,4 +1,4 @@ -# Copyright 2017, David Wilson +# Copyright 2019, David Wilson # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/ansible_mitogen/plugins/connection/mitogen_jail.py b/ansible_mitogen/plugins/connection/mitogen_jail.py index fb7bce54..c7475fb1 100644 --- a/ansible_mitogen/plugins/connection/mitogen_jail.py +++ b/ansible_mitogen/plugins/connection/mitogen_jail.py @@ -1,4 +1,4 @@ -# Copyright 2017, David Wilson +# Copyright 2019, David Wilson # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/ansible_mitogen/plugins/connection/mitogen_local.py b/ansible_mitogen/plugins/connection/mitogen_local.py index fcd9c030..24b84a03 100644 --- a/ansible_mitogen/plugins/connection/mitogen_local.py +++ b/ansible_mitogen/plugins/connection/mitogen_local.py @@ -1,4 +1,4 @@ -# Copyright 2017, David Wilson +# Copyright 2019, David Wilson # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/ansible_mitogen/plugins/connection/mitogen_lxc.py b/ansible_mitogen/plugins/connection/mitogen_lxc.py index ce394102..696c9abd 100644 --- a/ansible_mitogen/plugins/connection/mitogen_lxc.py +++ b/ansible_mitogen/plugins/connection/mitogen_lxc.py @@ -1,4 +1,4 @@ -# Copyright 2017, David Wilson +# Copyright 2019, David Wilson # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/ansible_mitogen/plugins/connection/mitogen_lxd.py b/ansible_mitogen/plugins/connection/mitogen_lxd.py index 77efe6c1..95e692a0 100644 --- a/ansible_mitogen/plugins/connection/mitogen_lxd.py +++ b/ansible_mitogen/plugins/connection/mitogen_lxd.py @@ -1,4 +1,4 @@ -# Copyright 2017, David Wilson +# Copyright 2019, David Wilson # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/ansible_mitogen/plugins/connection/mitogen_machinectl.py b/ansible_mitogen/plugins/connection/mitogen_machinectl.py index 9b332a3f..0f5a0d28 100644 --- a/ansible_mitogen/plugins/connection/mitogen_machinectl.py +++ b/ansible_mitogen/plugins/connection/mitogen_machinectl.py @@ -1,4 +1,4 @@ -# Copyright 2017, David Wilson +# Copyright 2019, David Wilson # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/ansible_mitogen/plugins/connection/mitogen_setns.py b/ansible_mitogen/plugins/connection/mitogen_setns.py index 23f62135..20c6f137 100644 --- a/ansible_mitogen/plugins/connection/mitogen_setns.py +++ b/ansible_mitogen/plugins/connection/mitogen_setns.py @@ -1,4 +1,4 @@ -# Copyright 2017, David Wilson +# Copyright 2019, David Wilson # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/ansible_mitogen/plugins/connection/mitogen_ssh.py b/ansible_mitogen/plugins/connection/mitogen_ssh.py index dbaba407..df0e87cb 100644 --- a/ansible_mitogen/plugins/connection/mitogen_ssh.py +++ b/ansible_mitogen/plugins/connection/mitogen_ssh.py @@ -1,4 +1,4 @@ -# Copyright 2017, David Wilson +# Copyright 2019, David Wilson # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/ansible_mitogen/plugins/connection/mitogen_su.py b/ansible_mitogen/plugins/connection/mitogen_su.py index 104a7190..4ab2711e 100644 --- a/ansible_mitogen/plugins/connection/mitogen_su.py +++ b/ansible_mitogen/plugins/connection/mitogen_su.py @@ -1,4 +1,4 @@ -# Copyright 2017, David Wilson +# Copyright 2019, David Wilson # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/ansible_mitogen/plugins/connection/mitogen_sudo.py b/ansible_mitogen/plugins/connection/mitogen_sudo.py index 367dd61b..130f5445 100644 --- a/ansible_mitogen/plugins/connection/mitogen_sudo.py +++ b/ansible_mitogen/plugins/connection/mitogen_sudo.py @@ -1,4 +1,4 @@ -# Copyright 2017, David Wilson +# Copyright 2019, David Wilson # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/ansible_mitogen/plugins/strategy/mitogen.py b/ansible_mitogen/plugins/strategy/mitogen.py index f8608745..66872663 100644 --- a/ansible_mitogen/plugins/strategy/mitogen.py +++ b/ansible_mitogen/plugins/strategy/mitogen.py @@ -1,4 +1,4 @@ -# Copyright 2017, David Wilson +# Copyright 2019, David Wilson # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/ansible_mitogen/plugins/strategy/mitogen_free.py b/ansible_mitogen/plugins/strategy/mitogen_free.py index d3b1cdc6..ffe2fbd9 100644 --- a/ansible_mitogen/plugins/strategy/mitogen_free.py +++ b/ansible_mitogen/plugins/strategy/mitogen_free.py @@ -1,4 +1,4 @@ -# Copyright 2017, David Wilson +# Copyright 2019, David Wilson # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/ansible_mitogen/plugins/strategy/mitogen_host_pinned.py b/ansible_mitogen/plugins/strategy/mitogen_host_pinned.py index 175e1f8b..23eccd36 100644 --- a/ansible_mitogen/plugins/strategy/mitogen_host_pinned.py +++ b/ansible_mitogen/plugins/strategy/mitogen_host_pinned.py @@ -1,4 +1,4 @@ -# Copyright 2017, David Wilson +# Copyright 2019, David Wilson # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/ansible_mitogen/plugins/strategy/mitogen_linear.py b/ansible_mitogen/plugins/strategy/mitogen_linear.py index 51b03096..1b198e61 100644 --- a/ansible_mitogen/plugins/strategy/mitogen_linear.py +++ b/ansible_mitogen/plugins/strategy/mitogen_linear.py @@ -1,4 +1,4 @@ -# Copyright 2017, David Wilson +# Copyright 2019, David Wilson # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/ansible_mitogen/process.py b/ansible_mitogen/process.py index 32f4a012..d7f36496 100644 --- a/ansible_mitogen/process.py +++ b/ansible_mitogen/process.py @@ -1,4 +1,4 @@ -# Copyright 2017, David Wilson +# Copyright 2019, David Wilson # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/ansible_mitogen/runner.py b/ansible_mitogen/runner.py index 768cc57c..04c70e78 100644 --- a/ansible_mitogen/runner.py +++ b/ansible_mitogen/runner.py @@ -1,4 +1,4 @@ -# Copyright 2017, David Wilson +# Copyright 2019, David Wilson # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/ansible_mitogen/services.py b/ansible_mitogen/services.py index 61286382..a7c0e46f 100644 --- a/ansible_mitogen/services.py +++ b/ansible_mitogen/services.py @@ -1,4 +1,4 @@ -# Copyright 2017, David Wilson +# Copyright 2019, David Wilson # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/ansible_mitogen/strategy.py b/ansible_mitogen/strategy.py index 4d1636e2..50486841 100644 --- a/ansible_mitogen/strategy.py +++ b/ansible_mitogen/strategy.py @@ -1,4 +1,4 @@ -# Copyright 2017, David Wilson +# Copyright 2019, David Wilson # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/ansible_mitogen/target.py b/ansible_mitogen/target.py index e891730e..809165da 100644 --- a/ansible_mitogen/target.py +++ b/ansible_mitogen/target.py @@ -1,4 +1,4 @@ -# Copyright 2017, David Wilson +# Copyright 2019, David Wilson # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/ansible_mitogen/transport_config.py b/ansible_mitogen/transport_config.py index edc9ce1e..8ef12165 100644 --- a/ansible_mitogen/transport_config.py +++ b/ansible_mitogen/transport_config.py @@ -1,4 +1,4 @@ -# Copyright 2017, David Wilson +# Copyright 2019, David Wilson # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: @@ -497,7 +497,6 @@ class MitogenViaSpec(Spec): def become_pass(self): return optional_secret( - # TODO: Might have to come from PlayContext. self._host_vars.get('ansible_become_password') or self._host_vars.get('ansible_become_pass') ) @@ -510,6 +509,7 @@ class MitogenViaSpec(Spec): def port(self): return ( + self._host_vars.get('ansible_ssh_port') or self._host_vars.get('ansible_port') or C.DEFAULT_REMOTE_PORT ) diff --git a/docs/_static/style.css b/docs/_static/style.css index 98dd4bac..456473a9 100644 --- a/docs/_static/style.css +++ b/docs/_static/style.css @@ -3,6 +3,10 @@ body { font-size: 100%; } +.sphinxsidebarwrapper { + padding-top: 0 !important; +} + .sphinxsidebar { font-size: 80% !important; } diff --git a/docs/_templates/globaltoc.html b/docs/_templates/globaltoc.html new file mode 100644 index 00000000..76accef7 --- /dev/null +++ b/docs/_templates/globaltoc.html @@ -0,0 +1 @@ +{{ toctree() }} diff --git a/docs/changelog.rst b/docs/changelog.rst index e7ce61c3..84162bf8 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -144,6 +144,9 @@ Fixes * `#538 `_: the Mitogen source distribution includes a requisite ``LICENSE`` file. +* `#539 `_: log output is no longer + duplicated when the Ansible ``log_path`` setting is enabled. + * `#540 `_: the ``stderr`` stream of async module invocations was previously discarded. @@ -158,6 +161,9 @@ Fixes ``ansible_become_method`` variable is respected when ``mitogen_via=`` is active. +* `7fd0d349 `_: the + ``ansible_ssh_port`` variable is respected when ``mitogen_via=`` is active. + Thanks! ~~~~~~~ diff --git a/mitogen/__init__.py b/mitogen/__init__.py index 26e48aff..060430c6 100644 --- a/mitogen/__init__.py +++ b/mitogen/__init__.py @@ -1,4 +1,4 @@ -# Copyright 2017, David Wilson +# Copyright 2019, David Wilson # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/mitogen/core.py b/mitogen/core.py index 9f329d88..920a94b6 100644 --- a/mitogen/core.py +++ b/mitogen/core.py @@ -1,4 +1,4 @@ -# Copyright 2017, David Wilson +# Copyright 2019, David Wilson # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/mitogen/debug.py b/mitogen/debug.py index 8f290c4d..3d13347f 100644 --- a/mitogen/debug.py +++ b/mitogen/debug.py @@ -1,4 +1,4 @@ -# Copyright 2017, David Wilson +# Copyright 2019, David Wilson # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/mitogen/doas.py b/mitogen/doas.py index 250b6faf..1b687fb2 100644 --- a/mitogen/doas.py +++ b/mitogen/doas.py @@ -1,4 +1,4 @@ -# Copyright 2017, David Wilson +# Copyright 2019, David Wilson # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/mitogen/docker.py b/mitogen/docker.py index 074f0e90..0c0d40e7 100644 --- a/mitogen/docker.py +++ b/mitogen/docker.py @@ -1,4 +1,4 @@ -# Copyright 2017, David Wilson +# Copyright 2019, David Wilson # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/mitogen/fakessh.py b/mitogen/fakessh.py index 2f2726eb..d39a710d 100644 --- a/mitogen/fakessh.py +++ b/mitogen/fakessh.py @@ -1,4 +1,4 @@ -# Copyright 2017, David Wilson +# Copyright 2019, David Wilson # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/mitogen/fork.py b/mitogen/fork.py index 081f7e3d..c78558b8 100644 --- a/mitogen/fork.py +++ b/mitogen/fork.py @@ -1,4 +1,4 @@ -# Copyright 2017, David Wilson +# Copyright 2019, David Wilson # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/mitogen/jail.py b/mitogen/jail.py index fade8cbb..6e0ac68b 100644 --- a/mitogen/jail.py +++ b/mitogen/jail.py @@ -1,4 +1,4 @@ -# Copyright 2017, David Wilson +# Copyright 2019, David Wilson # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/mitogen/lxc.py b/mitogen/lxc.py index 6d4acba6..879d19a1 100644 --- a/mitogen/lxc.py +++ b/mitogen/lxc.py @@ -1,4 +1,4 @@ -# Copyright 2017, David Wilson +# Copyright 2019, David Wilson # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/mitogen/lxd.py b/mitogen/lxd.py index 7de4903a..faea2561 100644 --- a/mitogen/lxd.py +++ b/mitogen/lxd.py @@ -1,4 +1,4 @@ -# Copyright 2017, David Wilson +# Copyright 2019, David Wilson # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/mitogen/master.py b/mitogen/master.py index 18323844..1396f4e1 100644 --- a/mitogen/master.py +++ b/mitogen/master.py @@ -1,4 +1,4 @@ -# Copyright 2017, David Wilson +# Copyright 2019, David Wilson # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/mitogen/parent.py b/mitogen/parent.py index 814d20e3..7e567aaa 100644 --- a/mitogen/parent.py +++ b/mitogen/parent.py @@ -1,4 +1,4 @@ -# Copyright 2017, David Wilson +# Copyright 2019, David Wilson # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/mitogen/profiler.py b/mitogen/profiler.py index 10ec6086..74bbdb23 100644 --- a/mitogen/profiler.py +++ b/mitogen/profiler.py @@ -1,4 +1,4 @@ -# Copyright 2017, David Wilson +# Copyright 2019, David Wilson # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/mitogen/select.py b/mitogen/select.py index 6b87e671..fd2cbe9a 100644 --- a/mitogen/select.py +++ b/mitogen/select.py @@ -1,4 +1,4 @@ -# Copyright 2017, David Wilson +# Copyright 2019, David Wilson # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/mitogen/service.py b/mitogen/service.py index c67b35e8..0fba59c9 100644 --- a/mitogen/service.py +++ b/mitogen/service.py @@ -1,4 +1,4 @@ -# Copyright 2017, David Wilson +# Copyright 2019, David Wilson # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/mitogen/setns.py b/mitogen/setns.py index d38aa092..b1d69783 100644 --- a/mitogen/setns.py +++ b/mitogen/setns.py @@ -1,4 +1,4 @@ -# Copyright 2017, David Wilson +# Copyright 2019, David Wilson # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/mitogen/ssh.py b/mitogen/ssh.py index 47c90fff..11b74c1b 100644 --- a/mitogen/ssh.py +++ b/mitogen/ssh.py @@ -1,4 +1,4 @@ -# Copyright 2017, David Wilson +# Copyright 2019, David Wilson # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/mitogen/su.py b/mitogen/su.py index 7eff60a6..5ff9e177 100644 --- a/mitogen/su.py +++ b/mitogen/su.py @@ -1,4 +1,4 @@ -# Copyright 2017, David Wilson +# Copyright 2019, David Wilson # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/mitogen/sudo.py b/mitogen/sudo.py index 05a04989..868d4d76 100644 --- a/mitogen/sudo.py +++ b/mitogen/sudo.py @@ -1,4 +1,4 @@ -# Copyright 2017, David Wilson +# Copyright 2019, David Wilson # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/mitogen/unix.py b/mitogen/unix.py index 3e315d6f..66141eec 100644 --- a/mitogen/unix.py +++ b/mitogen/unix.py @@ -1,4 +1,4 @@ -# Copyright 2017, David Wilson +# Copyright 2019, David Wilson # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/mitogen/utils.py b/mitogen/utils.py index 6c56d6d5..94a171fb 100644 --- a/mitogen/utils.py +++ b/mitogen/utils.py @@ -1,4 +1,4 @@ -# Copyright 2017, David Wilson +# Copyright 2019, David Wilson # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/setup.py b/setup.py index 6f31133d..c3257996 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,5 @@ #!/usr/bin/env python2 -# Copyright 2017, David Wilson +# Copyright 2019, David Wilson # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/tests/ansible/hosts/transport_config.hosts b/tests/ansible/hosts/transport_config.hosts index c98d4f41..d68b2d84 100644 --- a/tests/ansible/hosts/transport_config.hosts +++ b/tests/ansible/hosts/transport_config.hosts @@ -31,3 +31,19 @@ tc-become-set # become_method() tc-become-method-unset tc-become-method-su ansible_become_method=su + +# become_user() +tc-become-user-unset +tc-become-user-set ansible_become_user=ansi-become-user + +# become_pass() +tc-become-pass-unset +tc-become-pass-password ansible_become_password=apassword +tc-become-pass-pass ansible_become_pass=apass +tc-become-pass-both ansible_become_password=a.b.c ansible_become_pass=c.b.a + +# port() +tc-port-unset +tc-port-explicit-port ansible_port=1234 +tc-port-explicit-ssh ansible_ssh_port=4321 +tc-port-both ansible_port=1717 ansible_ssh_port=1532 diff --git a/tests/ansible/integration/transport_config/all.yml b/tests/ansible/integration/transport_config/all.yml index 908f6735..64199314 100644 --- a/tests/ansible/integration/transport_config/all.yml +++ b/tests/ansible/integration/transport_config/all.yml @@ -1,6 +1,9 @@ -- include: become.yml - include: become_method.yml +- include: become_pass.yml +- include: become_user.yml +- include: become.yml - include: password.yml +- include: port.yml - include: python_path.yml - include: remote_addr.yml - include: remote_user.yml diff --git a/tests/ansible/integration/transport_config/become_pass.yml b/tests/ansible/integration/transport_config/become_pass.yml new file mode 100644 index 00000000..02c6528d --- /dev/null +++ b/tests/ansible/integration/transport_config/become_pass.yml @@ -0,0 +1,142 @@ +# Each case is followed by mitogen_via= case to test hostvars pass. + + +# No become-pass set, defaults to "root" +- name: integration/transport_config/become-pass.yml + hosts: tc-become-pass-unset + become: true + tasks: + - include: ../_mitogen_only.yml + - {mitogen_get_stack: {}, register: out} + - assert: + that: + - out.result|length == 2 + - out.result[0].method == "ssh" + - out.result[1].method == "sudo" + - out.result[1].kwargs.password == None + +# Not set, unbecoming mitogen_via= +- hosts: tc-become-pass-unset + become: true + vars: {mitogen_via: tc-become-pass-password} + tasks: + - include: ../_mitogen_only.yml + - {mitogen_get_stack: {}, register: out} + - assert: + that: + - out.result|length == 3 + - out.result[0].method == "ssh" + - out.result[1].method == "ssh" + - out.result[2].method == "sudo" + - out.result[2].kwargs.password == None + +# Not set, becoming mitogen_via= +- hosts: tc-become-pass-unset + become: true + vars: {mitogen_via: viapass@tc-become-pass-password} + tasks: + - include: ../_mitogen_only.yml + - {mitogen_get_stack: {}, register: out} + - assert: + that: + - out.result|length == 4 + - out.result[0].method == "ssh" + - out.result[1].method == "sudo" + - out.result[1].kwargs.password == "apassword" + - out.result[2].method == "ssh" + - out.result[3].method == "sudo" + - out.result[3].kwargs.password == None + + +# ansible_become_password= set. +- hosts: tc-become-pass-password + become: true + tasks: + - include: ../_mitogen_only.yml + - {mitogen_get_stack: {}, register: out} + - assert: + that: + - out.result|length == 2 + - out.result[0].method == "ssh" + - out.result[1].method == "sudo" + - out.result[1].kwargs.password == "apassword" + + +# ansible_become_password=, via= +- hosts: tc-become-pass-password + vars: {mitogen_via: root@tc-become-pass-pass} + become: true + tasks: + - include: ../_mitogen_only.yml + - {mitogen_get_stack: {}, register: out} + - assert: + that: + - out.result|length == 4 + - out.result[0].method == "ssh" + - out.result[1].method == "sudo" + - out.result[1].kwargs.password == "apass" + - out.result[2].method == "ssh" + - out.result[3].method == "sudo" + - out.result[3].kwargs.password == "apassword" + + +# ansible_become_pass= +- hosts: tc-become-pass-pass + become: true + tasks: + - include: ../_mitogen_only.yml + - {mitogen_get_stack: {}, register: out} + - assert: + that: + - out.result|length == 2 + - out.result[0].method == "ssh" + - out.result[1].method == "sudo" + - out.result[1].kwargs.password == "apass" + + +# ansible_become_pass=, via= +- hosts: tc-become-pass-pass + vars: {mitogen_via: root@tc-become-pass-password} + become: true + tasks: + - include: ../_mitogen_only.yml + - {mitogen_get_stack: {}, register: out} + - assert: + that: + - out.result|length == 4 + - out.result[0].method == "ssh" + - out.result[1].method == "sudo" + - out.result[1].kwargs.password == "apassword" + - out.result[2].method == "ssh" + - out.result[3].method == "sudo" + - out.result[3].kwargs.password == "apass" + + + +# ansible_become_pass & ansible_become_password set, password takes precedence +- hosts: tc-become-pass-both + become: true + tasks: + - include: ../_mitogen_only.yml + - {mitogen_get_stack: {}, register: out} + - assert: + that: + - out.result|length == 2 + - out.result[0].method == "ssh" + - out.result[1].method == "sudo" + - out.result[1].kwargs.password == "a.b.c" + + +# both, mitogen_via +- hosts: tc-become-pass-unset + vars: {mitogen_via: root@tc-become-pass-both} + tasks: + - include: ../_mitogen_only.yml + - {mitogen_get_stack: {}, register: out} + - assert: + that: + - out.result|length == 3 + - out.result[0].method == "ssh" + - out.result[1].method == "sudo" + - out.result[1].kwargs.password == "a.b.c" + - out.result[2].method == "ssh" diff --git a/tests/ansible/integration/transport_config/become_user.yml b/tests/ansible/integration/transport_config/become_user.yml new file mode 100644 index 00000000..43cbca2a --- /dev/null +++ b/tests/ansible/integration/transport_config/become_user.yml @@ -0,0 +1,106 @@ +# Each case is followed by mitogen_via= case to test hostvars user. + + +# No become-user set, defaults to "root" +- name: integration/transport_config/become-user.yml + hosts: tc-become-user-unset + become: true + tasks: + - include: ../_mitogen_only.yml + - {mitogen_get_stack: {}, register: out} + - assert: + that: + - out.result|length == 2 + - out.result[0].method == "ssh" + - out.result[1].method == "sudo" + - out.result[1].kwargs.username == "root" + +# Not set, unbecoming mitogen_via= +- hosts: tc-become-user-unset + become: true + vars: {mitogen_via: tc-become-user-set} + tasks: + - include: ../_mitogen_only.yml + - {mitogen_get_stack: {}, register: out} + - assert: + that: + - out.result|length == 3 + - out.result[0].method == "ssh" + - out.result[1].method == "ssh" + - out.result[2].method == "sudo" + - out.result[2].kwargs.username == "root" + +# Not set, becoming mitogen_via= +- hosts: tc-become-user-unset + become: true + vars: {mitogen_via: viauser@tc-become-user-set} + tasks: + - include: ../_mitogen_only.yml + - {mitogen_get_stack: {}, register: out} + - assert: + that: + - out.result|length == 4 + - out.result[0].method == "ssh" + - out.result[1].method == "sudo" + - out.result[1].kwargs.username == "viauser" + - out.result[2].method == "ssh" + - out.result[3].method == "sudo" + - out.result[3].kwargs.username == "root" + + +# ansible_become_user= set. +- hosts: tc-become-user-set + become: true + tasks: + - include: ../_mitogen_only.yml + - {mitogen_get_stack: {}, register: out} + - assert: + that: + - out.result|length == 2 + - out.result[0].method == "ssh" + - out.result[1].method == "sudo" + - out.result[1].kwargs.username == "ansi-become-user" + + +# ansible_become_user=, unbecoming via= +- hosts: tc-become-user-set + vars: {mitogen_via: tc-become-user-unset} + become: true + tasks: + - include: ../_mitogen_only.yml + - {mitogen_get_stack: {}, register: out} + - assert: + that: + - out.result|length == 3 + - out.result[0].method == "ssh" + - out.result[0].kwargs.hostname == "tc-become-user-unset" + + - out.result[1].method == "ssh" + - out.result[1].kwargs.hostname == "tc-become-user-set" + + - out.result[2].method == "sudo" + - out.result[2].kwargs.username == "ansi-become-user" + + +# ansible_become_user=, becoming via= +- hosts: tc-become-user-set + vars: {mitogen_via: "doas:doasuser@tc-become-user-unset"} + become: true + tasks: + - include: ../_mitogen_only.yml + - {mitogen_get_stack: {}, register: out} + - assert: + that: + - out.result|length == 4 + - out.result[0].method == "ssh" + - out.result[0].kwargs.hostname == "tc-become-user-unset" + + - out.result[1].method == "doas" + - out.result[1].kwargs.username == "doasuser" + + - out.result[2].method == "ssh" + - out.result[2].kwargs.hostname == "tc-become-user-set" + + - out.result[3].method == "sudo" + - out.result[3].kwargs.username == "ansi-become-user" + diff --git a/tests/ansible/integration/transport_config/port.yml b/tests/ansible/integration/transport_config/port.yml new file mode 100644 index 00000000..2781081a --- /dev/null +++ b/tests/ansible/integration/transport_config/port.yml @@ -0,0 +1,101 @@ +# Each case is followed by mitogen_via= case to test hostvars pass. + + +# No port set +- name: integration/transport_config/port.yml + hosts: tc-port-unset + tasks: + - include: ../_mitogen_only.yml + - {mitogen_get_stack: {}, register: out} + - assert: + that: + - out.result|length == 1 + - out.result[0].method == "ssh" + - out.result[0].kwargs.port == None + +# Not set, mitogen_via= +- hosts: tc-port-explicit-ssh + vars: {mitogen_via: tc-port-unset} + tasks: + - include: ../_mitogen_only.yml + - {mitogen_get_stack: {}, register: out} + - assert: + that: + - out.result|length == 2 + - out.result[0].method == "ssh" + - out.result[0].kwargs.port == None + - out.result[1].method == "ssh" + - out.result[1].kwargs.port == 4321 + +# ansible_ssh_port= +- hosts: tc-port-explicit-ssh + tasks: + - include: ../_mitogen_only.yml + - {mitogen_get_stack: {}, register: out} + - assert: + that: + - out.result|length == 1 + - out.result[0].method == "ssh" + - out.result[0].kwargs.port == 4321 + +- hosts: tc-port-explicit-unset + vars: {mitogen_via: tc-port-explicit-ssh} + tasks: + - include: ../_mitogen_only.yml + - {mitogen_get_stack: {}, register: out} + - assert: + that: + - out.result|length == 2 + - out.result[0].method == "ssh" + - out.result[1].kwargs.port == 4321 + - out.result[1].method == "ssh" + - out.result[0].kwargs.port == None + +# ansible_port= +- hosts: tc-port-explicit-port + tasks: + - include: ../_mitogen_only.yml + - {mitogen_get_stack: {}, register: out} + - assert: + that: + - out.result|length == 1 + - out.result[0].method == "ssh" + - out.result[0].kwargs.port == 1234 + +- hosts: tc-port-unset + vars: {mitogen_via: tc-port-explicit-port} + tasks: + - include: ../_mitogen_only.yml + - {mitogen_get_stack: {}, register: out} + - assert: + that: + - out.result|length == 2 + - out.result[0].method == "ssh" + - out.result[0].kwargs.port == 1234 + - out.result[1].method == "ssh" + - out.result[1].kwargs.port == None + + +# both, ssh takes precedence +- hosts: tc-port-both + tasks: + - include: ../_mitogen_only.yml + - {mitogen_get_stack: {}, register: out} + - assert: + that: + - out.result|length == 1 + - out.result[0].method == "ssh" + - out.result[0].kwargs.port == 1532 + +- hosts: tc-port-unset + vars: {mitogen_via: tc-port-both} + tasks: + - include: ../_mitogen_only.yml + - {mitogen_get_stack: {}, register: out} + - assert: + that: + - out.result|length == 2 + - out.result[0].method == "ssh" + - out.result[0].kwargs.port == 1532 + - out.result[1].method == "ssh" + - out.result[1].kwargs.port == None