diff --git a/tests/ansible/hosts/transport_config.hosts b/tests/ansible/hosts/transport_config.hosts index d9685811..ac046dd5 100644 --- a/tests/ansible/hosts/transport_config.hosts +++ b/tests/ansible/hosts/transport_config.hosts @@ -1,10 +1,13 @@ # 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 - -# local connections get virtualenv python path tc-python-path-local-unset ansible_connection=local tc-python-path-local-explicit ansible_connection=local ansible_python_interpreter=/a/b/c - diff --git a/tests/ansible/integration/transport_config/all.yml b/tests/ansible/integration/transport_config/all.yml index 704760d1..cd3f7ac2 100644 --- a/tests/ansible/integration/transport_config/all.yml +++ b/tests/ansible/integration/transport_config/all.yml @@ -1,2 +1,2 @@ - - include: python_path.yml +- include: transport.yml diff --git a/tests/ansible/integration/transport_config/python_path.yml b/tests/ansible/integration/transport_config/python_path.yml index db6c873b..c5359e93 100644 --- a/tests/ansible/integration/transport_config/python_path.yml +++ b/tests/ansible/integration/transport_config/python_path.yml @@ -8,8 +8,7 @@ hosts: tc-python-path-unset tasks: - include: ../_mitogen_only.yml - - mitogen_get_stack: - register: out + - {mitogen_get_stack: {}, register: out} - assert_equal: left: out.result[0].kwargs.python_path right: ["/usr/bin/python"] @@ -18,8 +17,7 @@ vars: {mitogen_via: tc-python-path-unset} tasks: - include: ../_mitogen_only.yml - - mitogen_get_stack: - register: out + - {mitogen_get_stack: {}, register: out} - assert_equal: left: out.result[0].kwargs.python_path right: ["/usr/bin/python"] @@ -32,8 +30,7 @@ - hosts: tc-python-path-hostvar tasks: - include: ../_mitogen_only.yml - - mitogen_get_stack: - register: out + - {mitogen_get_stack: {}, register: out} - assert_equal: left: out.result[0].kwargs.python_path right: [/hostvar/path/to/python] @@ -42,8 +39,7 @@ vars: {mitogen_via: tc-python-path-hostvar} tasks: - include: ../_mitogen_only.yml - - mitogen_get_stack: - register: out + - {mitogen_get_stack: {}, register: out} - assert_equal: left: out.result[0].kwargs.python_path right: ["/hostvar/path/to/python"] @@ -56,8 +52,7 @@ - hosts: localhost tasks: - include: ../_mitogen_only.yml - - mitogen_get_stack: - register: out + - {mitogen_get_stack: {}, register: out} - assert_equal: left: out.result[0].kwargs.python_path right: ["{{ansible_playbook_python}}"] @@ -66,8 +61,7 @@ vars: {mitogen_via: localhost} tasks: - include: ../_mitogen_only.yml - - mitogen_get_stack: - register: out + - {mitogen_get_stack: {}, register: out} - assert_equal: left: out.result[0].kwargs.python_path right: ["{{ansible_playbook_python}}"] @@ -80,8 +74,7 @@ - hosts: tc-python-path-local-unset tasks: - include: ../_mitogen_only.yml - - mitogen_get_stack: - register: out + - {mitogen_get_stack: {}, register: out} - assert_equal: left: out.result[0].kwargs.python_path right: ["/usr/bin/python"] @@ -90,8 +83,7 @@ vars: {mitogen_via: tc-python-path-local-unset} tasks: - include: ../_mitogen_only.yml - - mitogen_get_stack: - register: out + - {mitogen_get_stack: {}, register: out} - assert_equal: left: out.result[0].kwargs.python_path right: ["/usr/bin/python"] @@ -104,8 +96,7 @@ - hosts: tc-python-path-local-explicit tasks: - include: ../_mitogen_only.yml - - mitogen_get_stack: - register: out + - {mitogen_get_stack: {}, register: out} - assert_equal: left: out.result[0].kwargs.python_path right: ["/a/b/c"] @@ -114,8 +105,7 @@ vars: {mitogen_via: tc-python-path-local-explicit} tasks: - include: ../_mitogen_only.yml - - mitogen_get_stack: - register: out + - {mitogen_get_stack: {}, register: out} - assert_equal: left: out.result[0].kwargs.python_path right: ["/a/b/c"] diff --git a/tests/ansible/integration/transport_config/transport.yml b/tests/ansible/integration/transport_config/transport.yml new file mode 100644 index 00000000..efedc8d4 --- /dev/null +++ b/tests/ansible/integration/transport_config/transport.yml @@ -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"