You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mitogen/tests/ansible/integration/transport_config/become_user.yml

107 lines
3.0 KiB
YAML

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