Merge remote-tracking branch 'origin/dmw' into stable
* origin/dmw: issue #537: disable just the trivial LinuxPolicyTest on Travis. docs: update Changelog; closes #537. ansible: refactor affinity class and add abstract tests. Bump version for release. docs: update Changelog. core: serialize calls to _service_stub_main(). docs: update Changelog; closes #532. issue #532: PushFileService race. docs: more concise Changelog. issue #541: changelog typos. ansible: quiesce boto logger; closes #541. 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. ansible: capture stderr stream of async tasks. Closes #540. docs: update Changelog. issue #536: rework how 2.3-compatible simplejson is served .github: add some more questions to issue template docs: duplicate word docs: update Changelog. tests/ansible: Spec.become_method() test & mitogen_via= fix. setup.py: include LICENSE; closes #538. tests/ansible: Spec.become() test tests/ansible: Spec.password() test, document interactive pw limitation. tests/ansible: Spec.remote_user() test & mitogen_via= fix. tests/ansible: Spec.remote_addr() test & mitogen_via= fix. tests/ansible: Spec.transport() test. docs: lighter pink docs: add 'Fixes' heading docs: more margin tweaks for changelog docs: tighter <p> margins, even less shouting, red headings docs: tidy up footer and GitHub link docs: enable fixed_sidebar docs: sans-serif fonts, reduce shouty headings issue #536: add mitogen_via= tests too. ansible: fix a crash on 2.3 when mitogen_via= host is missing. tests: for 2.3 compatibility, disable gcloud.py for now docs: update Changelog; closes #511, closes #536. docs: update Changelog release date. issue #536: disable transport_config tests on vanilla issue #536: restore correct Python interpreter selection behaviour. issue #536: connection_delegation/ tests were erroneously broken tests: define MITOGEN_INVENTORY_FILE even if -i unspecified. issue #536: add tests for each ansible_python_interpreter case. issue #536: stop defining explicit localhost in inventory. tests: allow running Ansible tests locally without -udmw again. stable: fix preamble_size on stable docs. issue #481: add test.pull/862/head v0.2.5
commit
ae80d42cb4
@ -0,0 +1 @@
|
||||
include LICENSE
|
@ -1,8 +1,4 @@
|
||||
<p>
|
||||
<br>
|
||||
<a class="github-button" href="https://github.com/dw/mitogen" data-size="large" data-show-count="true" aria-label="Star dw/mitogen on GitHub">Star</a>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<a href="https://github.com/dw/mitogen/">GitHub Repository</a>
|
||||
<a class="github-button" href="https://github.com/dw/mitogen/" data-size="large" data-show-count="true" aria-label="Star dw/mitogen on GitHub">Star</a>
|
||||
</p>
|
||||
|
@ -0,0 +1 @@
|
||||
{{ toctree() }}
|
@ -1,8 +1,9 @@
|
||||
# vim: syntax=dosini
|
||||
|
||||
# When running the tests outside CI, make a single 'target' host which is the
|
||||
# local machine.
|
||||
target ansible_host=localhost
|
||||
# local machine. The ansible_user override is necessary since some tests want a
|
||||
# fixed ansible.cfg remote_user setting to test against.
|
||||
target ansible_host=localhost ansible_user="{{lookup('env', 'USER')}}"
|
||||
|
||||
[test-targets]
|
||||
target
|
||||
|
@ -0,0 +1,49 @@
|
||||
# integration/transport_config
|
||||
# Hosts with twiddled configs that need to be checked somehow.
|
||||
|
||||
|
||||
# tansport()
|
||||
tc-transport-unset
|
||||
tc-transport-local ansible_connection=local
|
||||
|
||||
# python_path()
|
||||
tc-python-path-unset
|
||||
tc-python-path-hostvar ansible_python_interpreter=/hostvar/path/to/python
|
||||
tc-python-path-local-unset ansible_connection=local
|
||||
tc-python-path-local-explicit ansible_connection=local ansible_python_interpreter=/a/b/c
|
||||
|
||||
# remote_addr()
|
||||
tc-remote-addr-unset # defaults to inventory_hostname
|
||||
tc-remote-addr-explicit-ssh ansible_ssh_host=ansi.ssh.host
|
||||
tc-remote-addr-explicit-host ansible_host=ansi.host
|
||||
tc-remote-addr-explicit-both ansible_ssh_host=a.b.c ansible_host=b.c.d
|
||||
|
||||
# password()
|
||||
tc-password-unset
|
||||
tc-password-explicit-ssh ansible_ssh_pass=ansi-ssh-pass
|
||||
tc-password-explicit-user ansible_password=ansi-pass
|
||||
tc-password-explicit-both ansible_password=a.b.c ansible_ssh_pass=c.b.a
|
||||
|
||||
# become()
|
||||
tc-become-unset
|
||||
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
|
@ -0,0 +1,4 @@
|
||||
# Include me for plays that can't run on vanilla.
|
||||
#
|
||||
- meta: end_play
|
||||
when: not is_mitogen
|
@ -0,0 +1,7 @@
|
||||
|
||||
# Tests for correct selection of connection variables.
|
||||
|
||||
This directory is a placeholder for a work-in-progress test set that tries
|
||||
every combination of the variables extracted via `transport_config.py`.
|
||||
|
||||
In the meantime, it has ad-hoc scripts for bugs already encountered.
|
@ -0,0 +1,10 @@
|
||||
- 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
|
||||
- include: transport.yml
|
@ -0,0 +1,68 @@
|
||||
# Each case is followed by mitogen_via= case to test hostvars method.
|
||||
|
||||
|
||||
# No become set.
|
||||
- name: integration/transport_config/become.yml
|
||||
hosts: tc-become-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.username == "ansible-cfg-remote-user"
|
||||
|
||||
- hosts: tc-become-unset
|
||||
vars: {mitogen_via: becomeuser@tc-become-set}
|
||||
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.username == "ansible-cfg-remote-user"
|
||||
|
||||
- out.result[1].method == "sudo"
|
||||
- out.result[1].kwargs.username == "becomeuser"
|
||||
|
||||
- out.result[2].method == "ssh"
|
||||
- out.result[2].kwargs.hostname == "tc-become-unset"
|
||||
|
||||
|
||||
# Become set.
|
||||
- name: integration/transport_config/become.yml
|
||||
hosts: tc-become-set
|
||||
become: true
|
||||
become_user: becomeuser
|
||||
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.username == "ansible-cfg-remote-user"
|
||||
- out.result[1].method == "sudo"
|
||||
- out.result[1].kwargs.username == "becomeuser"
|
||||
|
||||
- hosts: tc-become-set
|
||||
vars: {mitogen_via: tc-become-unset}
|
||||
become: true
|
||||
become_user: becomeuser
|
||||
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-unset"
|
||||
- out.result[0].kwargs.username == "ansible-cfg-remote-user"
|
||||
|
||||
- out.result[1].method == "ssh"
|
||||
- out.result[1].kwargs.hostname == "tc-become-set"
|
||||
|
||||
- out.result[2].method == "sudo"
|
||||
- out.result[2].kwargs.username == "becomeuser"
|
@ -0,0 +1,83 @@
|
||||
# Each case is followed by mitogen_via= case to test hostvars method.
|
||||
|
||||
|
||||
# No become-method set.
|
||||
- name: integration/transport_config/become-method.yml
|
||||
hosts: tc-become-method-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"
|
||||
|
||||
- hosts: tc-become-method-unset
|
||||
vars: {mitogen_via: becomeuser@tc-become-method-su}
|
||||
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 == "su"
|
||||
- out.result[1].kwargs.username == "becomeuser"
|
||||
- out.result[2].method == "ssh"
|
||||
- out.result[2].kwargs.hostname == "tc-become-method-unset"
|
||||
|
||||
|
||||
# ansible_become_method=su
|
||||
- hosts: tc-become-method-su
|
||||
become: true
|
||||
become_user: becomeuser
|
||||
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 == "su"
|
||||
- out.result[1].kwargs.username == "becomeuser"
|
||||
|
||||
- hosts: tc-become-method-su
|
||||
vars: {mitogen_via: tc-become-method-unset}
|
||||
become: true
|
||||
become_user: becomeuser
|
||||
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-method-unset"
|
||||
|
||||
- out.result[1].method == "ssh"
|
||||
- out.result[1].kwargs.hostname == "tc-become-method-su"
|
||||
|
||||
- out.result[2].method == "su"
|
||||
- out.result[2].kwargs.username == "becomeuser"
|
||||
|
||||
|
||||
|
||||
# mitogen_via used to specify explicit become method
|
||||
- hosts: tc-become-method-unset
|
||||
vars: {mitogen_via: "doas:doasuser@tc-become-method-su"}
|
||||
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-method-su"
|
||||
|
||||
- out.result[1].method == "doas"
|
||||
- out.result[1].kwargs.username == "doasuser"
|
||||
|
||||
- out.result[2].method == "ssh"
|
||||
- out.result[2].kwargs.hostname == "tc-become-method-unset"
|
@ -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,94 @@
|
||||
# Each case is followed by mitogen_via= case to test hostvars method.
|
||||
|
||||
|
||||
# When no ansible_ssh_pass/ansible_password= is set, password comes via
|
||||
# interactive input.
|
||||
- name: integration/transport_config/password.yml
|
||||
hosts: tc-password-unset
|
||||
tasks:
|
||||
- include: ../_mitogen_only.yml
|
||||
- {mitogen_get_stack: {}, register: out}
|
||||
- assert_equal:
|
||||
left: out.result[0].kwargs.password
|
||||
right: "" # actually null, but assert_equal limitation
|
||||
|
||||
- hosts: tc-password-unset
|
||||
vars: {mitogen_via: tc-password-explicit-ssh}
|
||||
tasks:
|
||||
- include: ../_mitogen_only.yml
|
||||
- {mitogen_get_stack: {}, register: out}
|
||||
- assert_equal:
|
||||
left: out.result[0].kwargs.password
|
||||
right: "ansi-ssh-pass"
|
||||
- assert_equal:
|
||||
left: out.result[1].kwargs.password
|
||||
right: ""
|
||||
|
||||
|
||||
# ansible_ssh_user=
|
||||
|
||||
- hosts: tc-password-explicit-ssh
|
||||
tasks:
|
||||
- include: ../_mitogen_only.yml
|
||||
- {mitogen_get_stack: {}, register: out}
|
||||
- assert_equal:
|
||||
left: out.result[0].kwargs.password
|
||||
right: "ansi-ssh-pass"
|
||||
|
||||
- hosts: tc-password-explicit-ssh
|
||||
vars: {mitogen_via: tc-password-unset}
|
||||
tasks:
|
||||
- include: ../_mitogen_only.yml
|
||||
- {mitogen_get_stack: {}, register: out}
|
||||
- assert_equal:
|
||||
left: out.result[0].kwargs.password
|
||||
right: ""
|
||||
- assert_equal:
|
||||
left: out.result[1].kwargs.password
|
||||
right: "ansi-ssh-pass"
|
||||
|
||||
|
||||
# ansible_user=
|
||||
|
||||
- hosts: tc-password-explicit-pass
|
||||
tasks:
|
||||
- include: ../_mitogen_only.yml
|
||||
- {mitogen_get_stack: {}, register: out}
|
||||
- assert_equal:
|
||||
left: out.result[0].kwargs.password
|
||||
right: "ansi-pass"
|
||||
|
||||
- hosts: tc-password-explicit-pass
|
||||
vars: {mitogen_via: tc-password-unset}
|
||||
tasks:
|
||||
- include: ../_mitogen_only.yml
|
||||
- {mitogen_get_stack: {}, register: out}
|
||||
- assert_equal:
|
||||
left: out.result[0].kwargs.password
|
||||
right: ""
|
||||
- assert_equal:
|
||||
left: out.result[1].kwargs.password
|
||||
right: "ansi-pass"
|
||||
|
||||
|
||||
# both; ansible_ssh_user= takes precedence according to play_context.py.
|
||||
|
||||
- hosts: tc-password-explicit-both
|
||||
tasks:
|
||||
- include: ../_mitogen_only.yml
|
||||
- {mitogen_get_stack: {}, register: out}
|
||||
- assert_equal:
|
||||
left: out.result[0].kwargs.password
|
||||
right: "c.b.a"
|
||||
|
||||
- hosts: tc-password-explicit-both
|
||||
vars: {mitogen_via: tc-password-unset}
|
||||
tasks:
|
||||
- include: ../_mitogen_only.yml
|
||||
- {mitogen_get_stack: {}, register: out}
|
||||
- assert_equal:
|
||||
left: out.result[0].kwargs.password
|
||||
right: ""
|
||||
- assert_equal:
|
||||
left: out.result[1].kwargs.password
|
||||
right: "c.b.a"
|
@ -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
|
@ -0,0 +1,114 @@
|
||||
# related: issue #511, #536
|
||||
# Each case is followed by mitogen_via= case to test hostvars method.
|
||||
|
||||
|
||||
# When no ansible_python_interpreter is set, executor/module_common.py chooses
|
||||
# "/usr/bin/python".
|
||||
- name: integration/transport_config/python_path.yml
|
||||
hosts: tc-python-path-unset
|
||||
tasks:
|
||||
- include: ../_mitogen_only.yml
|
||||
- {mitogen_get_stack: {}, register: out}
|
||||
- assert_equal:
|
||||
left: out.result[0].kwargs.python_path
|
||||
right: ["/usr/bin/python"]
|
||||
|
||||
- hosts: tc-python-path-hostvar
|
||||
vars: {mitogen_via: tc-python-path-unset}
|
||||
tasks:
|
||||
- include: ../_mitogen_only.yml
|
||||
- {mitogen_get_stack: {}, register: out}
|
||||
- assert_equal:
|
||||
left: out.result[0].kwargs.python_path
|
||||
right: ["/usr/bin/python"]
|
||||
- assert_equal:
|
||||
left: out.result[1].kwargs.python_path
|
||||
right: ["/hostvar/path/to/python"]
|
||||
|
||||
|
||||
# Non-localhost with explicit ansible_python_interpreter
|
||||
- hosts: tc-python-path-hostvar
|
||||
tasks:
|
||||
- include: ../_mitogen_only.yml
|
||||
- {mitogen_get_stack: {}, register: out}
|
||||
- assert_equal:
|
||||
left: out.result[0].kwargs.python_path
|
||||
right: [/hostvar/path/to/python]
|
||||
|
||||
- hosts: tc-python-path-unset
|
||||
vars: {mitogen_via: tc-python-path-hostvar}
|
||||
tasks:
|
||||
- include: ../_mitogen_only.yml
|
||||
- {mitogen_get_stack: {}, register: out}
|
||||
- assert_equal:
|
||||
left: out.result[0].kwargs.python_path
|
||||
right: ["/hostvar/path/to/python"]
|
||||
- assert_equal:
|
||||
left: out.result[1].kwargs.python_path
|
||||
right: ["/usr/bin/python"]
|
||||
|
||||
|
||||
# Implicit localhost gets ansible_python_interpreter=virtualenv interpreter
|
||||
- hosts: localhost
|
||||
tasks:
|
||||
- include: ../_mitogen_only.yml
|
||||
- {mitogen_get_stack: {}, register: out}
|
||||
- assert_equal:
|
||||
left: out.result[0].kwargs.python_path
|
||||
right: ["{{ansible_playbook_python}}"]
|
||||
|
||||
- hosts: tc-python-path-unset
|
||||
vars: {mitogen_via: localhost}
|
||||
tasks:
|
||||
- include: ../_mitogen_only.yml
|
||||
- {mitogen_get_stack: {}, register: out}
|
||||
- assert_equal:
|
||||
left: out.result[0].kwargs.python_path
|
||||
right: ["{{ansible_playbook_python}}"]
|
||||
- assert_equal:
|
||||
left: out.result[1].kwargs.python_path
|
||||
right: ["/usr/bin/python"]
|
||||
|
||||
|
||||
# explicit local connections get the same treatment as everything else.
|
||||
- hosts: tc-python-path-local-unset
|
||||
tasks:
|
||||
- include: ../_mitogen_only.yml
|
||||
- {mitogen_get_stack: {}, register: out}
|
||||
- assert_equal:
|
||||
left: out.result[0].kwargs.python_path
|
||||
right: ["/usr/bin/python"]
|
||||
|
||||
- hosts: localhost
|
||||
vars: {mitogen_via: tc-python-path-local-unset}
|
||||
tasks:
|
||||
- include: ../_mitogen_only.yml
|
||||
- {mitogen_get_stack: {}, register: out}
|
||||
- assert_equal:
|
||||
left: out.result[0].kwargs.python_path
|
||||
right: ["/usr/bin/python"]
|
||||
- assert_equal:
|
||||
left: out.result[1].kwargs.python_path
|
||||
right: ["{{ansible_playbook_python}}"]
|
||||
|
||||
|
||||
# explicit local connection with explicit interpreter
|
||||
- hosts: tc-python-path-local-explicit
|
||||
tasks:
|
||||
- include: ../_mitogen_only.yml
|
||||
- {mitogen_get_stack: {}, register: out}
|
||||
- assert_equal:
|
||||
left: out.result[0].kwargs.python_path
|
||||
right: ["/a/b/c"]
|
||||
|
||||
- hosts: localhost
|
||||
vars: {mitogen_via: tc-python-path-local-explicit}
|
||||
tasks:
|
||||
- include: ../_mitogen_only.yml
|
||||
- {mitogen_get_stack: {}, register: out}
|
||||
- assert_equal:
|
||||
left: out.result[0].kwargs.python_path
|
||||
right: ["/a/b/c"]
|
||||
- assert_equal:
|
||||
left: out.result[1].kwargs.python_path
|
||||
right: ["{{ansible_playbook_python}}"]
|
@ -0,0 +1,95 @@
|
||||
|
||||
# Each case is followed by mitogen_via= case to test hostvars method.
|
||||
|
||||
|
||||
# When no ansible_host/ansible_ssh_host= is set, hostname is same as inventory
|
||||
# name.
|
||||
- name: integration/transport_config/remote_addr.yml
|
||||
hosts: tc-remote-addr-unset
|
||||
tasks:
|
||||
- include: ../_mitogen_only.yml
|
||||
- {mitogen_get_stack: {}, register: out}
|
||||
- assert_equal:
|
||||
left: out.result[0].kwargs.hostname
|
||||
right: "tc-remote-addr-unset"
|
||||
|
||||
- hosts: tc-remote-addr-unset
|
||||
vars: {mitogen_via: tc-remote-addr-explicit-ssh}
|
||||
tasks:
|
||||
- include: ../_mitogen_only.yml
|
||||
- {mitogen_get_stack: {}, register: out}
|
||||
- assert_equal:
|
||||
left: out.result[0].kwargs.hostname
|
||||
right: "ansi.ssh.host"
|
||||
- assert_equal:
|
||||
left: out.result[1].kwargs.hostname
|
||||
right: "tc-remote-addr-unset"
|
||||
|
||||
|
||||
# ansible_ssh_host=
|
||||
|
||||
- hosts: tc-remote-addr-explicit-ssh
|
||||
tasks:
|
||||
- include: ../_mitogen_only.yml
|
||||
- {mitogen_get_stack: {}, register: out}
|
||||
- assert_equal:
|
||||
left: out.result[0].kwargs.hostname
|
||||
right: "ansi.ssh.host"
|
||||
|
||||
- hosts: tc-remote-addr-explicit-ssh
|
||||
vars: {mitogen_via: tc-remote-addr-unset}
|
||||
tasks:
|
||||
- include: ../_mitogen_only.yml
|
||||
- {mitogen_get_stack: {}, register: out}
|
||||
- assert_equal:
|
||||
left: out.result[0].kwargs.hostname
|
||||
right: "tc-remote-addr-unset"
|
||||
- assert_equal:
|
||||
left: out.result[1].kwargs.hostname
|
||||
right: "ansi.ssh.host"
|
||||
|
||||
|
||||
# ansible_host=
|
||||
|
||||
- hosts: tc-remote-addr-explicit-host
|
||||
tasks:
|
||||
- include: ../_mitogen_only.yml
|
||||
- {mitogen_get_stack: {}, register: out}
|
||||
- assert_equal:
|
||||
left: out.result[0].kwargs.hostname
|
||||
right: "ansi.host"
|
||||
|
||||
- hosts: tc-remote-addr-explicit-host
|
||||
vars: {mitogen_via: tc-remote-addr-unset}
|
||||
tasks:
|
||||
- include: ../_mitogen_only.yml
|
||||
- {mitogen_get_stack: {}, register: out}
|
||||
- assert_equal:
|
||||
left: out.result[0].kwargs.hostname
|
||||
right: "tc-remote-addr-unset"
|
||||
- assert_equal:
|
||||
left: out.result[1].kwargs.hostname
|
||||
right: "ansi.host"
|
||||
|
||||
|
||||
# both; ansible_ssh_host= takes precedence according to play_context.py.
|
||||
|
||||
- hosts: tc-remote-addr-explicit-both
|
||||
tasks:
|
||||
- include: ../_mitogen_only.yml
|
||||
- {mitogen_get_stack: {}, register: out}
|
||||
- assert_equal:
|
||||
left: out.result[0].kwargs.hostname
|
||||
right: "a.b.c"
|
||||
|
||||
- hosts: tc-remote-addr-explicit-both
|
||||
vars: {mitogen_via: tc-remote-addr-unset}
|
||||
tasks:
|
||||
- include: ../_mitogen_only.yml
|
||||
- {mitogen_get_stack: {}, register: out}
|
||||
- assert_equal:
|
||||
left: out.result[0].kwargs.hostname
|
||||
right: "tc-remote-addr-unset"
|
||||
- assert_equal:
|
||||
left: out.result[1].kwargs.hostname
|
||||
right: "a.b.c"
|
@ -0,0 +1,96 @@
|
||||
|
||||
# Each case is followed by mitogen_via= case to test hostvars method.
|
||||
|
||||
|
||||
# When no ansible_user/ansible_ssh_user= is set, username is
|
||||
# C.DEFAULT_REMOTE_USER.
|
||||
- name: integration/transport_config/remote_user.yml
|
||||
hosts: tc-remote-user-unset
|
||||
tasks:
|
||||
- include: ../_mitogen_only.yml
|
||||
- {mitogen_get_stack: {}, register: out}
|
||||
- assert_equal:
|
||||
left: out.result[0].kwargs.username
|
||||
# We set DEFAULT_REMOTE_USER in our ansible.cfg
|
||||
right: "ansible-cfg-remote-user"
|
||||
|
||||
- hosts: tc-remote-user-unset
|
||||
vars: {mitogen_via: tc-remote-user-explicit-ssh}
|
||||
tasks:
|
||||
- include: ../_mitogen_only.yml
|
||||
- {mitogen_get_stack: {}, register: out}
|
||||
- assert_equal:
|
||||
left: out.result[0].kwargs.username
|
||||
right: "ansi-ssh-user"
|
||||
- assert_equal:
|
||||
left: out.result[1].kwargs.username
|
||||
right: "ansible-cfg-remote-user"
|
||||
|
||||
|
||||
# ansible_ssh_user=
|
||||
|
||||
- hosts: tc-remote-user-explicit-ssh
|
||||
tasks:
|
||||
- include: ../_mitogen_only.yml
|
||||
- {mitogen_get_stack: {}, register: out}
|
||||
- assert_equal:
|
||||
left: out.result[0].kwargs.username
|
||||
right: "ansi-ssh-user"
|
||||
|
||||
- hosts: tc-remote-user-explicit-ssh
|
||||
vars: {mitogen_via: tc-remote-user-unset}
|
||||
tasks:
|
||||
- include: ../_mitogen_only.yml
|
||||
- {mitogen_get_stack: {}, register: out}
|
||||
- assert_equal:
|
||||
left: out.result[0].kwargs.username
|
||||
right: "ansible-cfg-remote-user"
|
||||
- assert_equal:
|
||||
left: out.result[1].kwargs.username
|
||||
right: "ansi-ssh-user"
|
||||
|
||||
|
||||
# ansible_user=
|
||||
|
||||
- hosts: tc-remote-user-explicit-user
|
||||
tasks:
|
||||
- include: ../_mitogen_only.yml
|
||||
- {mitogen_get_stack: {}, register: out}
|
||||
- assert_equal:
|
||||
left: out.result[0].kwargs.username
|
||||
right: "ansi-user"
|
||||
|
||||
- hosts: tc-remote-user-explicit-host
|
||||
vars: {mitogen_via: tc-remote-user-unset}
|
||||
tasks:
|
||||
- include: ../_mitogen_only.yml
|
||||
- {mitogen_get_stack: {}, register: out}
|
||||
- assert_equal:
|
||||
left: out.result[0].kwargs.username
|
||||
right: "ansible-cfg-remote-user"
|
||||
- assert_equal:
|
||||
left: out.result[1].kwargs.username
|
||||
right: "ansi-user"
|
||||
|
||||
|
||||
# both; ansible_ssh_user= takes precedence according to play_context.py.
|
||||
|
||||
- hosts: tc-remote-user-explicit-both
|
||||
tasks:
|
||||
- include: ../_mitogen_only.yml
|
||||
- {mitogen_get_stack: {}, register: out}
|
||||
- assert_equal:
|
||||
left: out.result[0].kwargs.username
|
||||
right: "c.b.a"
|
||||
|
||||
- hosts: tc-remote-user-explicit-both
|
||||
vars: {mitogen_via: tc-remote-user-unset}
|
||||
tasks:
|
||||
- include: ../_mitogen_only.yml
|
||||
- {mitogen_get_stack: {}, register: out}
|
||||
- assert_equal:
|
||||
left: out.result[0].kwargs.username
|
||||
right: "ansible-cfg-remote-user"
|
||||
- assert_equal:
|
||||
left: out.result[1].kwargs.username
|
||||
right: "c.b.a"
|
@ -0,0 +1,48 @@
|
||||
# Each case is followed by mitogen_via= case to test hostvars method.
|
||||
|
||||
|
||||
# When no ansible_connection= is set, transport comes via ansible.cfg ("smart"
|
||||
# is parsed away to either paramiko or ssh).
|
||||
- name: integration/transport_config/transport.yml
|
||||
hosts: tc-transport-unset
|
||||
tasks:
|
||||
- include: ../_mitogen_only.yml
|
||||
- {mitogen_get_stack: {}, register: out}
|
||||
- assert_equal:
|
||||
left: out.result[0].method
|
||||
right: "ssh"
|
||||
|
||||
- hosts: tc-transport-local
|
||||
vars: {mitogen_via: tc-transport-unset}
|
||||
tasks:
|
||||
- include: ../_mitogen_only.yml
|
||||
- {mitogen_get_stack: {}, register: out}
|
||||
- assert_equal:
|
||||
left: out.result[0].method
|
||||
right: "ssh"
|
||||
- assert_equal:
|
||||
left: out.result[1].method
|
||||
right: "local"
|
||||
|
||||
|
||||
# ansible_connection=local
|
||||
|
||||
- hosts: tc-transport-local
|
||||
tasks:
|
||||
- include: ../_mitogen_only.yml
|
||||
- {mitogen_get_stack: {}, register: out}
|
||||
- assert_equal:
|
||||
left: out.result[0].method
|
||||
right: "local"
|
||||
|
||||
- hosts: tc-transport-unset
|
||||
vars: {mitogen_via: tc-transport-local}
|
||||
tasks:
|
||||
- include: ../_mitogen_only.yml
|
||||
- {mitogen_get_stack: {}, register: out}
|
||||
- assert_equal:
|
||||
left: out.result[0].method
|
||||
right: "local"
|
||||
- assert_equal:
|
||||
left: out.result[1].method
|
||||
right: "ssh"
|
@ -0,0 +1,56 @@
|
||||
|
||||
import os
|
||||
import tempfile
|
||||
import unittest2
|
||||
|
||||
import mitogen.core
|
||||
import mitogen.service
|
||||
import testlib
|
||||
from mitogen.core import b
|
||||
|
||||
|
||||
def prepare():
|
||||
# ensure module loading delay is complete before loading PushFileService.
|
||||
pass
|
||||
|
||||
|
||||
@mitogen.core.takes_router
|
||||
def wait_for_file(path, router):
|
||||
pool = mitogen.service.get_or_create_pool(router=router)
|
||||
service = pool.get_service(u'mitogen.service.PushFileService')
|
||||
return service.get(path)
|
||||
|
||||
|
||||
class PropagateToTest(testlib.RouterMixin, testlib.TestCase):
|
||||
klass = mitogen.service.PushFileService
|
||||
|
||||
def test_two_grandchild_one_intermediary(self):
|
||||
tf = tempfile.NamedTemporaryFile()
|
||||
path = mitogen.core.to_text(tf.name)
|
||||
|
||||
try:
|
||||
tf.write(b('test'))
|
||||
tf.flush()
|
||||
|
||||
interm = self.router.local(name='interm')
|
||||
c1 = self.router.local(via=interm, name='c1')
|
||||
c2 = self.router.local(via=interm)
|
||||
|
||||
c1.call(prepare)
|
||||
c2.call(prepare)
|
||||
|
||||
service = self.klass(router=self.router)
|
||||
service.propagate_to(context=c1, path=path)
|
||||
service.propagate_to(context=c2, path=path)
|
||||
|
||||
s = c1.call(wait_for_file, path=path)
|
||||
self.assertEquals(b('test'), s)
|
||||
|
||||
s = c2.call(wait_for_file, path=path)
|
||||
self.assertEquals(b('test'), s)
|
||||
finally:
|
||||
tf.close()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest2.main()
|
Loading…
Reference in New Issue