tests/ansible: Spec.become_user() test.

pull/564/head
David Wilson 6 years ago
parent 968b826800
commit 7b3ed52fd8

@ -31,3 +31,7 @@ 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

@ -1,5 +1,6 @@
- include: become.yml
- include: become_method.yml
- include: become_user.yml
- include: password.yml
- include: python_path.yml
- include: remote_addr.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"
Loading…
Cancel
Save