From a77f07659e9dcb355901dc5224e18f8f93ef7cf8 Mon Sep 17 00:00:00 2001 From: David Wilson Date: Wed, 31 Oct 2018 01:10:41 +0000 Subject: [PATCH] issue #409: make setns test to work anywhere sudo works. --- .../stub_connections/setns_lxc.yml | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/tests/ansible/integration/stub_connections/setns_lxc.yml b/tests/ansible/integration/stub_connections/setns_lxc.yml index bc37aa8e..739047c5 100644 --- a/tests/ansible/integration/stub_connections/setns_lxc.yml +++ b/tests/ansible/integration/stub_connections/setns_lxc.yml @@ -6,12 +6,21 @@ - name: integration/stub_connections/setns_lxc.yml hosts: test-targets gather_facts: false - any_errors_fatal: true + any_errors_fatal: false connection: local tasks: - setup: register: out + - debug: msg={{out}} + + - command: sudo whoami + args: + warn: false + ignore_errors: true + register: sudo_available + when: out.ansible_facts.ansible_system == 'Linux' + - command: | sudo -E ansible -i localhost, @@ -24,7 +33,14 @@ args: chdir: ../.. warn: false + when: | + out.ansible_facts.ansible_system == 'Linux' + and sudo_available.rc == 0 + register: result + + - assert: + that: | + (out.ansible_facts.ansible_system != 'Linux') or + (sudo_available != 0) or + (result.rc == 0) - # TODO: we don't know if sudo works on this machine, so hard wire it for - # me and for Travis CI. - when: out.ansible_facts.ansible_user_id in ['dmw', 'travis']