Merge remote-tracking branch 'origin/issue499'

* origin/issue499:
  issue #499: another totally moronic implementation difference
  issue #499: disable new test on vanilla.
  docs: update Changelog; closes #499.
  issue #499: respect C.BECOME_ALLOW_SAME_USER.
issue510
David Wilson 6 years ago
commit fba06b0bde

@ -587,7 +587,8 @@ class Connection(ansible.plugins.connection.ConnectionBase):
) )
stack += (CONNECTION_METHOD[spec.transport()](spec),) stack += (CONNECTION_METHOD[spec.transport()](spec),)
if spec.become(): if spec.become() and ((spec.become_user() != spec.remote_user()) or
C.BECOME_ALLOW_SAME_USER):
stack += (CONNECTION_METHOD[spec.become_method()](spec),) stack += (CONNECTION_METHOD[spec.become_method()](spec),)
return stack return stack

@ -260,6 +260,9 @@ Fixes
trigger early finalization of Cython-based extension modules, leading to trigger early finalization of Cython-based extension modules, leading to
segmentation faults. segmentation faults.
* `#499 <https://github.com/dw/mitogen/issues/499>`_: the ``allow_same_user``
Ansible configuration setting is respected.
* `dc1d4251 <https://github.com/dw/mitogen/commit/dc1d4251>`_: the * `dc1d4251 <https://github.com/dw/mitogen/commit/dc1d4251>`_: the
``synchronize`` module could fail with the Docker transport due to a missing ``synchronize`` module could fail with the Docker transport due to a missing
attribute. attribute.

@ -0,0 +1,4 @@
# become_same_user.yml
bsu-joe ansible_user=joe

@ -22,6 +22,8 @@
raw: 'whoami' raw: 'whoami'
register: raw register: raw
- debug: msg="x{{raw}}x"
# Can't test stdout because TTY inserts \r in Ansible version. # Can't test stdout because TTY inserts \r in Ansible version.
- name: Verify raw module output. - name: Verify raw module output.
assert: assert:
@ -33,6 +35,7 @@
- | - |
raw.stdout_lines|to_text in ( raw.stdout_lines|to_text in (
["\r\n"], ["\r\n"],
["", "root"],
["root\r\n"], ["root\r\n"],
["root"], ["root"],
) )

@ -1,5 +1,6 @@
--- ---
- include: become_same_user.yml
- include: disconnect_during_module.yml - include: disconnect_during_module.yml
- include: disconnect_resets_connection.yml - include: disconnect_resets_connection.yml
- include: exec_command.yml - include: exec_command.yml

@ -0,0 +1,39 @@
# issue #499: ensure C.BECOME_ALLOW_SAME_USER is respected.
---
- name: integration/connection/become_same_user.yml
hosts: bsu-joe
gather_facts: no
any_errors_fatal: true
tasks:
# bsu-joe's login user is joe, so become should be ignored.
- mitogen_get_stack:
become: true
become_user: joe
register: out
when: is_mitogen
- assert:
that:
- out.result[0].method == "ssh"
- out.result[0].kwargs.username == "joe"
- out.result|length == 1 # no sudo
when: is_mitogen
# Now try with a different account.
- mitogen_get_stack:
become: true
become_user: james
register: out
when: is_mitogen
- assert:
that:
- out.result[0].method == "ssh"
- out.result[0].kwargs.username == "joe"
- out.result[1].method == "sudo"
- out.result[1].kwargs.username == "james"
- out.result|length == 2 # no sudo
when: is_mitogen
Loading…
Cancel
Save