|
| 1 | +# Each case is followed by mitogen_via= case to test hostvars method. |
| 2 | + |
| 3 | + |
| 4 | +# No become-method set. |
| 5 | +- name: integration/transport_config/become-method.yml |
| 6 | + hosts: tc-become-method-unset |
| 7 | + become: true |
| 8 | + tasks: |
| 9 | + - include: ../_mitogen_only.yml |
| 10 | + - {mitogen_get_stack: {}, register: out} |
| 11 | + - assert: |
| 12 | + that: |
| 13 | + - out.result|length == 2 |
| 14 | + - out.result[0].method == "ssh" |
| 15 | + - out.result[1].method == "sudo" |
| 16 | + |
| 17 | +- hosts: tc-become-method-unset |
| 18 | + vars: {mitogen_via: becomeuser@tc-become-method-su} |
| 19 | + tasks: |
| 20 | + - include: ../_mitogen_only.yml |
| 21 | + - {mitogen_get_stack: {}, register: out} |
| 22 | + - assert: |
| 23 | + that: |
| 24 | + - out.result|length == 3 |
| 25 | + - out.result[0].method == "ssh" |
| 26 | + - out.result[1].method == "su" |
| 27 | + - out.result[1].kwargs.username == "becomeuser" |
| 28 | + - out.result[2].method == "ssh" |
| 29 | + - out.result[2].kwargs.hostname == "tc-become-method-unset" |
| 30 | + |
| 31 | + |
| 32 | +# ansible_become_method=su |
| 33 | +- hosts: tc-become-method-su |
| 34 | + become: true |
| 35 | + become_user: becomeuser |
| 36 | + tasks: |
| 37 | + - include: ../_mitogen_only.yml |
| 38 | + - {mitogen_get_stack: {}, register: out} |
| 39 | + - assert: |
| 40 | + that: |
| 41 | + - out.result|length == 2 |
| 42 | + - out.result[0].method == "ssh" |
| 43 | + - out.result[1].method == "su" |
| 44 | + - out.result[1].kwargs.username == "becomeuser" |
| 45 | + |
| 46 | +- hosts: tc-become-method-su |
| 47 | + vars: {mitogen_via: tc-become-method-unset} |
| 48 | + become: true |
| 49 | + become_user: becomeuser |
| 50 | + tasks: |
| 51 | + - include: ../_mitogen_only.yml |
| 52 | + - {mitogen_get_stack: {}, register: out} |
| 53 | + - assert: |
| 54 | + that: |
| 55 | + - out.result|length == 3 |
| 56 | + - out.result[0].method == "ssh" |
| 57 | + - out.result[0].kwargs.hostname == "tc-become-method-unset" |
| 58 | + |
| 59 | + - out.result[1].method == "ssh" |
| 60 | + - out.result[1].kwargs.hostname == "tc-become-method-su" |
| 61 | + |
| 62 | + - out.result[2].method == "su" |
| 63 | + - out.result[2].kwargs.username == "becomeuser" |
| 64 | + |
| 65 | + |
| 66 | + |
| 67 | +# mitogen_via used to specify explicit become method |
| 68 | +- hosts: tc-become-method-unset |
| 69 | + vars: {mitogen_via: "doas:doasuser@tc-become-method-su"} |
| 70 | + tasks: |
| 71 | + - include: ../_mitogen_only.yml |
| 72 | + - {mitogen_get_stack: {}, register: out} |
| 73 | + - assert: |
| 74 | + that: |
| 75 | + - out.result|length == 3 |
| 76 | + - out.result[0].method == "ssh" |
| 77 | + - out.result[0].kwargs.hostname == "tc-become-method-su" |
| 78 | + |
| 79 | + - out.result[1].method == "doas" |
| 80 | + - out.result[1].kwargs.username == "doasuser" |
| 81 | + |
| 82 | + - out.result[2].method == "ssh" |
| 83 | + - out.result[2].kwargs.hostname == "tc-become-method-unset" |
0 commit comments