Merge remote-tracking branch 'origin/dmw'

* origin/dmw:
  docs: update Changelog.
  tests/ansible: Spec.port() test & mitogen_via= fix.
  Update copyright year everywhere.
  tests/ansible: Spec.become_pass() test.
  docs: remove top "Table of Contents" link
  docs: remove a little more top margin wastage
  tests/ansible: Spec.become_user() test.
  docs: update Changelog; closes #539.
  issue #539: disable logger propagation.
pull/564/head
David Wilson 6 years ago
commit 6727402526

@ -1,4 +1,4 @@
Copyright 2017, David Wilson Copyright 2019, David Wilson
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met: modification, are permitted provided that the following conditions are met:

@ -1,4 +1,4 @@
# Copyright 2017, David Wilson # Copyright 2019, David Wilson
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: # modification, are permitted provided that the following conditions are met:

@ -1,4 +1,4 @@
# Copyright 2017, David Wilson # Copyright 2019, David Wilson
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: # modification, are permitted provided that the following conditions are met:

@ -1,4 +1,4 @@
# Copyright 2017, David Wilson # Copyright 2019, David Wilson
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: # modification, are permitted provided that the following conditions are met:

@ -1,4 +1,4 @@
# Copyright 2017, David Wilson # Copyright 2019, David Wilson
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: # modification, are permitted provided that the following conditions are met:
@ -75,25 +75,28 @@ class Handler(logging.Handler):
def setup(): def setup():
""" """
Install a handler for Mitogen's logger to redirect it into the Ansible Install handlers for Mitogen loggers to redirect them into the Ansible
display framework, and prevent propagation to the root logger. 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)] l_mitogen = logging.getLogger('mitogen')
mitogen.core.LOG.handlers = [Handler(display.vvv)] l_mitogen_io = logging.getLogger('mitogen.io')
mitogen.core.IOLOG.handlers = [Handler(display.vvvv)] l_ansible_mitogen = logging.getLogger('ansible_mitogen')
mitogen.core.IOLOG.propagate = False
for logger in l_mitogen, l_mitogen_io, l_ansible_mitogen:
logger.handlers = [Handler(display.vvv)]
logger.propagate = False
if display.verbosity > 2: if display.verbosity > 2:
mitogen.core.LOG.setLevel(logging.DEBUG) l_ansible_mitogen.setLevel(logging.DEBUG)
logging.getLogger('ansible_mitogen').setLevel(logging.DEBUG) l_mitogen.setLevel(logging.DEBUG)
else: else:
# Mitogen copies the active log level into new children, allowing them # Mitogen copies the active log level into new children, allowing them
# to filter tiny messages before they hit the network, and therefore # to filter tiny messages before they hit the network, and therefore
# before they wake the IO loop. Explicitly setting INFO saves ~4% # before they wake the IO loop. Explicitly setting INFO saves ~4%
# running against just the local machine. # running against just the local machine.
mitogen.core.LOG.setLevel(logging.ERROR) l_mitogen.setLevel(logging.ERROR)
logging.getLogger('ansible_mitogen').setLevel(logging.ERROR) l_ansible_mitogen.setLevel(logging.ERROR)
if display.verbosity > 3: if display.verbosity > 3:
mitogen.core.IOLOG.setLevel(logging.DEBUG) l_mitogen_io.setLevel(logging.DEBUG)
logging.getLogger('ansible_mitogen').setLevel(logging.DEBUG)

@ -1,4 +1,4 @@
# Copyright 2017, David Wilson # Copyright 2019, David Wilson
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: # modification, are permitted provided that the following conditions are met:

@ -1,4 +1,4 @@
# Copyright 2017, David Wilson # Copyright 2019, David Wilson
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: # modification, are permitted provided that the following conditions are met:

@ -1,4 +1,4 @@
# Copyright 2017, David Wilson # Copyright 2019, David Wilson
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: # modification, are permitted provided that the following conditions are met:

@ -1,4 +1,4 @@
# Copyright 2017, David Wilson # Copyright 2019, David Wilson
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: # modification, are permitted provided that the following conditions are met:

@ -1,4 +1,4 @@
# Copyright 2017, David Wilson # Copyright 2019, David Wilson
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: # modification, are permitted provided that the following conditions are met:

@ -1,4 +1,4 @@
# Copyright 2017, David Wilson # Copyright 2019, David Wilson
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: # modification, are permitted provided that the following conditions are met:

@ -1,4 +1,4 @@
# Copyright 2017, David Wilson # Copyright 2019, David Wilson
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: # modification, are permitted provided that the following conditions are met:

@ -1,4 +1,4 @@
# Copyright 2017, David Wilson # Copyright 2019, David Wilson
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: # modification, are permitted provided that the following conditions are met:

@ -1,4 +1,4 @@
# Copyright 2017, David Wilson # Copyright 2019, David Wilson
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: # modification, are permitted provided that the following conditions are met:

@ -1,4 +1,4 @@
# Copyright 2017, David Wilson # Copyright 2019, David Wilson
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: # modification, are permitted provided that the following conditions are met:

@ -1,4 +1,4 @@
# Copyright 2017, David Wilson # Copyright 2019, David Wilson
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: # modification, are permitted provided that the following conditions are met:

@ -1,4 +1,4 @@
# Copyright 2017, David Wilson # Copyright 2019, David Wilson
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: # modification, are permitted provided that the following conditions are met:

@ -1,4 +1,4 @@
# Copyright 2017, David Wilson # Copyright 2019, David Wilson
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: # modification, are permitted provided that the following conditions are met:

@ -1,4 +1,4 @@
# Copyright 2017, David Wilson # Copyright 2019, David Wilson
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: # modification, are permitted provided that the following conditions are met:

@ -1,4 +1,4 @@
# Copyright 2017, David Wilson # Copyright 2019, David Wilson
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: # modification, are permitted provided that the following conditions are met:

@ -1,4 +1,4 @@
# Copyright 2017, David Wilson # Copyright 2019, David Wilson
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: # modification, are permitted provided that the following conditions are met:

@ -1,4 +1,4 @@
# Copyright 2017, David Wilson # Copyright 2019, David Wilson
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: # modification, are permitted provided that the following conditions are met:

@ -1,4 +1,4 @@
# Copyright 2017, David Wilson # Copyright 2019, David Wilson
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: # modification, are permitted provided that the following conditions are met:

@ -1,4 +1,4 @@
# Copyright 2017, David Wilson # Copyright 2019, David Wilson
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: # modification, are permitted provided that the following conditions are met:

@ -1,4 +1,4 @@
# Copyright 2017, David Wilson # Copyright 2019, David Wilson
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: # modification, are permitted provided that the following conditions are met:

@ -1,4 +1,4 @@
# Copyright 2017, David Wilson # Copyright 2019, David Wilson
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: # modification, are permitted provided that the following conditions are met:

@ -1,4 +1,4 @@
# Copyright 2017, David Wilson # Copyright 2019, David Wilson
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: # modification, are permitted provided that the following conditions are met:

@ -1,4 +1,4 @@
# Copyright 2017, David Wilson # Copyright 2019, David Wilson
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: # modification, are permitted provided that the following conditions are met:

@ -1,4 +1,4 @@
# Copyright 2017, David Wilson # Copyright 2019, David Wilson
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: # modification, are permitted provided that the following conditions are met:

@ -1,4 +1,4 @@
# Copyright 2017, David Wilson # Copyright 2019, David Wilson
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: # modification, are permitted provided that the following conditions are met:

@ -1,4 +1,4 @@
# Copyright 2017, David Wilson # Copyright 2019, David Wilson
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: # modification, are permitted provided that the following conditions are met:
@ -497,7 +497,6 @@ class MitogenViaSpec(Spec):
def become_pass(self): def become_pass(self):
return optional_secret( return optional_secret(
# TODO: Might have to come from PlayContext.
self._host_vars.get('ansible_become_password') or self._host_vars.get('ansible_become_password') or
self._host_vars.get('ansible_become_pass') self._host_vars.get('ansible_become_pass')
) )
@ -510,6 +509,7 @@ class MitogenViaSpec(Spec):
def port(self): def port(self):
return ( return (
self._host_vars.get('ansible_ssh_port') or
self._host_vars.get('ansible_port') or self._host_vars.get('ansible_port') or
C.DEFAULT_REMOTE_PORT C.DEFAULT_REMOTE_PORT
) )

@ -3,6 +3,10 @@ body {
font-size: 100%; font-size: 100%;
} }
.sphinxsidebarwrapper {
padding-top: 0 !important;
}
.sphinxsidebar { .sphinxsidebar {
font-size: 80% !important; font-size: 80% !important;
} }

@ -0,0 +1 @@
{{ toctree() }}

@ -144,6 +144,9 @@ Fixes
* `#538 <https://github.com/dw/mitogen/issues/538>`_: the Mitogen source * `#538 <https://github.com/dw/mitogen/issues/538>`_: the Mitogen source
distribution includes a requisite ``LICENSE`` file. distribution includes a requisite ``LICENSE`` file.
* `#539 <https://github.com/dw/mitogen/issues/539>`_: log output is no longer
duplicated when the Ansible ``log_path`` setting is enabled.
* `#540 <https://github.com/dw/mitogen/issues/540>`_: the ``stderr`` stream of * `#540 <https://github.com/dw/mitogen/issues/540>`_: the ``stderr`` stream of
async module invocations was previously discarded. async module invocations was previously discarded.
@ -158,6 +161,9 @@ Fixes
``ansible_become_method`` variable is respected when ``mitogen_via=`` is ``ansible_become_method`` variable is respected when ``mitogen_via=`` is
active. active.
* `7fd0d349 <https://github.com/dw/mitogen/commit/7fd0d349>`_: the
``ansible_ssh_port`` variable is respected when ``mitogen_via=`` is active.
Thanks! Thanks!
~~~~~~~ ~~~~~~~

@ -1,4 +1,4 @@
# Copyright 2017, David Wilson # Copyright 2019, David Wilson
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: # modification, are permitted provided that the following conditions are met:

@ -1,4 +1,4 @@
# Copyright 2017, David Wilson # Copyright 2019, David Wilson
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: # modification, are permitted provided that the following conditions are met:

@ -1,4 +1,4 @@
# Copyright 2017, David Wilson # Copyright 2019, David Wilson
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: # modification, are permitted provided that the following conditions are met:

@ -1,4 +1,4 @@
# Copyright 2017, David Wilson # Copyright 2019, David Wilson
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: # modification, are permitted provided that the following conditions are met:

@ -1,4 +1,4 @@
# Copyright 2017, David Wilson # Copyright 2019, David Wilson
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: # modification, are permitted provided that the following conditions are met:

@ -1,4 +1,4 @@
# Copyright 2017, David Wilson # Copyright 2019, David Wilson
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: # modification, are permitted provided that the following conditions are met:

@ -1,4 +1,4 @@
# Copyright 2017, David Wilson # Copyright 2019, David Wilson
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: # modification, are permitted provided that the following conditions are met:

@ -1,4 +1,4 @@
# Copyright 2017, David Wilson # Copyright 2019, David Wilson
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: # modification, are permitted provided that the following conditions are met:

@ -1,4 +1,4 @@
# Copyright 2017, David Wilson # Copyright 2019, David Wilson
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: # modification, are permitted provided that the following conditions are met:

@ -1,4 +1,4 @@
# Copyright 2017, David Wilson # Copyright 2019, David Wilson
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: # modification, are permitted provided that the following conditions are met:

@ -1,4 +1,4 @@
# Copyright 2017, David Wilson # Copyright 2019, David Wilson
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: # modification, are permitted provided that the following conditions are met:

@ -1,4 +1,4 @@
# Copyright 2017, David Wilson # Copyright 2019, David Wilson
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: # modification, are permitted provided that the following conditions are met:

@ -1,4 +1,4 @@
# Copyright 2017, David Wilson # Copyright 2019, David Wilson
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: # modification, are permitted provided that the following conditions are met:

@ -1,4 +1,4 @@
# Copyright 2017, David Wilson # Copyright 2019, David Wilson
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: # modification, are permitted provided that the following conditions are met:

@ -1,4 +1,4 @@
# Copyright 2017, David Wilson # Copyright 2019, David Wilson
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: # modification, are permitted provided that the following conditions are met:

@ -1,4 +1,4 @@
# Copyright 2017, David Wilson # Copyright 2019, David Wilson
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: # modification, are permitted provided that the following conditions are met:

@ -1,4 +1,4 @@
# Copyright 2017, David Wilson # Copyright 2019, David Wilson
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: # modification, are permitted provided that the following conditions are met:

@ -1,4 +1,4 @@
# Copyright 2017, David Wilson # Copyright 2019, David Wilson
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: # modification, are permitted provided that the following conditions are met:

@ -1,4 +1,4 @@
# Copyright 2017, David Wilson # Copyright 2019, David Wilson
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: # modification, are permitted provided that the following conditions are met:

@ -1,4 +1,4 @@
# Copyright 2017, David Wilson # Copyright 2019, David Wilson
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: # modification, are permitted provided that the following conditions are met:

@ -1,4 +1,4 @@
# Copyright 2017, David Wilson # Copyright 2019, David Wilson
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: # modification, are permitted provided that the following conditions are met:

@ -1,5 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# Copyright 2017, David Wilson # Copyright 2019, David Wilson
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: # modification, are permitted provided that the following conditions are met:

@ -31,3 +31,19 @@ tc-become-set
# become_method() # become_method()
tc-become-method-unset tc-become-method-unset
tc-become-method-su ansible_become_method=su 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

@ -1,6 +1,9 @@
- include: become.yml
- include: become_method.yml - include: become_method.yml
- include: become_pass.yml
- include: become_user.yml
- include: become.yml
- include: password.yml - include: password.yml
- include: port.yml
- include: python_path.yml - include: python_path.yml
- include: remote_addr.yml - include: remote_addr.yml
- include: remote_user.yml - include: remote_user.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"

@ -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"

@ -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
Loading…
Cancel
Save